agora inbox for [email protected]help / color / mirror / Atom feed
[PATCH 4/4] add force_incremental_sort GUC 387+ messages / 4 participants [nested] [flat]
* [PATCH 4/4] add force_incremental_sort GUC @ 2019-07-09 11:36 Tomas Vondra <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Tomas Vondra @ 2019-07-09 11:36 UTC (permalink / raw) --- src/backend/optimizer/path/costsize.c | 8 ++++++++ src/backend/utils/misc/guc.c | 10 ++++++++++ src/include/optimizer/cost.h | 1 + 3 files changed, 19 insertions(+) diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index c6aa17ba67..ee4487b158 100644 --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -140,6 +140,8 @@ bool enable_parallel_append = true; bool enable_parallel_hash = true; bool enable_partition_pruning = true; +bool force_incremental_sort = true; + typedef struct { PlannerInfo *root; @@ -1907,6 +1909,12 @@ cost_incremental_sort(Path *path, path->rows = input_tuples; path->startup_cost = startup_cost; path->total_cost = startup_cost + run_cost; + + if (force_incremental_sort) + { + path->startup_cost = input_startup_cost; + path->total_cost = input_total_cost; + } } /* diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index f922ee66a0..d2cc5b56b5 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -941,6 +941,16 @@ static struct config_bool ConfigureNamesBool[] = true, NULL, NULL, NULL }, + { + {"force_incremental_sort", PGC_USERSET, QUERY_TUNING_METHOD, + gettext_noop("Makes the incremental sort look like no-cost."), + NULL, + GUC_EXPLAIN + }, + &force_incremental_sort, + false, + NULL, NULL, NULL + }, { {"enable_incrementalsort", PGC_USERSET, QUERY_TUNING_METHOD, gettext_noop("Enables the planner's use of incremental sort steps."), diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h index b9d7a77e65..bad1d5a330 100644 --- a/src/include/optimizer/cost.h +++ b/src/include/optimizer/cost.h @@ -66,6 +66,7 @@ extern PGDLLIMPORT bool enable_parallel_append; extern PGDLLIMPORT bool enable_parallel_hash; extern PGDLLIMPORT bool enable_partition_pruning; extern PGDLLIMPORT int constraint_exclusion; +extern PGDLLIMPORT bool force_incremental_sort; extern double index_pages_fetched(double tuples_fetched, BlockNumber pages, double index_pages, PlannerInfo *root); -- 2.21.0 --z44ikx7gwyo2xwzv-- ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH] Improve documentation about our XML functionality. @ 2019-08-03 02:47 nobody <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: nobody @ 2019-08-03 02:47 UTC (permalink / raw) Add a section explaining how our XML features depart from current versions of the SQL standard. Update and clarify the descriptions of some XML functions. Chapman Flack, reviewed by Ryan Lambert Discussion: https://postgr.es/m/[email protected] Discussion: https://postgr.es/m/[email protected] Discussion: https://postgr.es/m/CAN-V+g-6JqUQEQZ55Q3toXEN6d5Ez5uvzL4VR+8KtvJKj31taw@mail.gmail.com This version for backpatching PG 11 and 10, taken from Tom's commit for 12, then edited to correctly describe behaviors that are fixed in 12 but still broken in 11 and 10. --- doc/src/sgml/datatype.sgml | 5 + doc/src/sgml/features.sgml | 381 ++++++++++++++++++++++++++++++++++- doc/src/sgml/func.sgml | 184 +++++++++-------- src/backend/catalog/sql_features.txt | 6 +- 4 files changed, 490 insertions(+), 86 deletions(-) diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 401a2f0..fa505e0 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -4228,6 +4228,11 @@ a0ee-bc99-9c0b-4ef8-bb6d-6bb9-bd38-0a11 value is a full document or only a content fragment. </para> + <para> + Limits and compatibility notes for the <type>xml</type> data type + can be found in <xref linkend="xml-limits-conformance"/>. + </para> + <sect2> <title>Creating XML Values</title> <para> diff --git a/doc/src/sgml/features.sgml b/doc/src/sgml/features.sgml index 6c22d69..253ec87 100644 --- a/doc/src/sgml/features.sgml +++ b/doc/src/sgml/features.sgml @@ -16,7 +16,8 @@ Language SQL</quote>. A revised version of the standard is released from time to time; the most recent update appearing in 2011. The 2011 version is referred to as ISO/IEC 9075:2011, or simply as SQL:2011. - The versions prior to that were SQL:2008, SQL:2003, SQL:1999, and SQL-92. Each version + The versions prior to that were SQL:2008, SQL:2006, SQL:2003, SQL:1999, + and SQL-92. Each version replaces the previous one, so claims of conformance to earlier versions have no official merit. <productname>PostgreSQL</productname> development aims for @@ -155,4 +156,382 @@ </para> </sect1> + <sect1 id="xml-limits-conformance"> + <title>XML Limits and Conformance to SQL/XML</title> + + <indexterm> + <primary>SQL/XML</primary> + <secondary>limits and conformance</secondary> + </indexterm> + + <para> + Significant revisions to the XML-related specifications in ISO/IEC 9075-14 + (SQL/XML) were introduced with SQL:2006. + <productname>PostgreSQL</productname>'s implementation of the XML data + type and related functions largely follows the earlier 2003 edition, + with some borrowing from later editions. In particular: + <itemizedlist> + <listitem> + <para> + Where the current standard provides a family of XML data types + to hold <quote>document</quote> or <quote>content</quote> in + untyped or XML Schema-typed variants, and a type + <type>XML(SEQUENCE)</type> to hold arbitrary pieces of XML content, + <productname>PostgreSQL</productname> provides the single + <type>xml</type> type, which can hold <quote>document</quote> or + <quote>content</quote>. There is no equivalent of the + standard's <quote>sequence</quote> type. + </para> + </listitem> + + <listitem> + <para> + <productname>PostgreSQL</productname> provides two functions + introduced in SQL:2006, but in variants that use the XPath 1.0 + language, rather than XML Query as specified for them in the + standard. + </para> + </listitem> + </itemizedlist> + </para> + + <para> + This section presents some of the resulting differences you may encounter. + </para> + + <sect2 id="functions-xml-limits-xpath1"> + <title>Queries are restricted to XPath 1.0</title> + + <para> + The <productname>PostgreSQL</productname>-specific functions + <function>xpath()</function> and <function>xpath_exists()</function> + query XML documents using the XPath language. + <productname>PostgreSQL</productname> also provides XPath-only variants + of the standard functions <function>XMLEXISTS</function> and + <function>XMLTABLE</function>, which officially use + the XQuery language. For all of these functions, + <productname>PostgreSQL</productname> relies on the + <application>libxml2</application> library, which provides only XPath 1.0. + </para> + + <para> + There is a strong connection between the XQuery language and XPath + versions 2.0 and later: any expression that is syntactically valid and + executes successfully in both produces the same result (with a minor + exception for expressions containing numeric character references or + predefined entity references, which XQuery replaces with the + corresponding character while XPath leaves them alone). But there is + no such connection between these languages and XPath 1.0; it was an + earlier language and differs in many respects. + </para> + + <para> + There are two categories of limitation to keep in mind: the restriction + from XQuery to XPath for the functions specified in the SQL standard, and + the restriction of XPath to version 1.0 for both the standard and the + <productname>PostgreSQL</productname>-specific functions. + </para> + + <sect3> + <title>Restriction of XQuery to XPath</title> + + <para> + Features of XQuery beyond those of XPath include: + + <itemizedlist> + <listitem> + <para> + XQuery expressions can construct and return new XML nodes, in + addition to all possible XPath values. XPath can create and return + values of the atomic types (numbers, strings, and so on) but can + only return XML nodes that were already present in documents + supplied as input to the expression. + </para> + </listitem> + + <listitem> + <para> + XQuery has control constructs for iteration, sorting, and grouping. + </para> + </listitem> + + <listitem> + <para> + XQuery allows declaration and use of local functions. + </para> + </listitem> + </itemizedlist> + </para> + + <para> + Recent XPath versions begin to offer capabilities overlapping with + these (such as functional-style <function>for-each</function> and + <function>sort</function>, anonymous functions, and + <function>parse-xml</function> to create a node from a string), + but such features were not available before XPath 3.0. + </para> + </sect3> + + <sect3 id="xml-xpath-1-specifics"> + <title>Restriction of XPath to 1.0</title> + + <para> + For developers familiar with XQuery and XPath 2.0 or later, XPath 1.0 + presents a number of differences to contend with: + + <itemizedlist> + <listitem> + <para> + The fundamental type of an XQuery/XPath expression, the + <type>sequence</type>, which can contain XML nodes, atomic values, + or both, does not exist in XPath 1.0. A 1.0 expression can only + produce a node-set (containing zero or more XML nodes), or a single + atomic value. + </para> + </listitem> + + <listitem> + <para> + Unlike an XQuery/XPath sequence, which can contain any desired + items in any desired order, an XPath 1.0 node-set has no + guaranteed order and, like any set, does not allow multiple + appearances of the same item. + <note> + <para> + The <application>libxml2</application> library does seem to + always return node-sets to <productname>PostgreSQL</productname> + with their members in the same relative order they had in the + input document. Its documentation does not commit to this + behavior, and an XPath 1.0 expression cannot control it. + </para> + </note> + </para> + </listitem> + + <listitem> + <para> + While XQuery/XPath provides all of the types defined in XML Schema + and many operators and functions over those types, XPath 1.0 has only + node-sets and the three atomic types <type>boolean</type>, + <type>double</type>, and <type>string</type>. + </para> + </listitem> + + <listitem> + <para> + XPath 1.0 has no conditional operator. An XQuery/XPath expression + such as <literal>if ( hat ) then hat/@size else "no hat"</literal> + has no XPath 1.0 equivalent. + </para> + </listitem> + + <listitem> + <para> + XPath 1.0 has no ordering comparison operator for strings. Both + <literal>"cat" < "dog"</literal> and + <literal>"cat" > "dog"</literal> are false, because each is a + numeric comparison of two <literal>NaN</literal>s. In contrast, + <literal>=</literal> and <literal>!=</literal> do compare the strings + as strings. + </para> + </listitem> + + <listitem> + <para> + XPath 1.0 blurs the distinction between + <firstterm>value comparisons</firstterm> and + <firstterm>general comparisons</firstterm> as XQuery/XPath define + them. Both <literal>sale/@hatsize = 7</literal> and + <literal>sale/@customer = "alice"</literal> are existentially + quantified comparisons, true if there is + any <literal>sale</literal> with the given value for the + attribute, but <literal>sale/@taxable = false()</literal> is a + value comparison to the + <firstterm>effective boolean value</firstterm> of a whole node-set. + It is true only if no <literal>sale</literal> has + a <literal>taxable</literal> attribute at all. + </para> + </listitem> + + <listitem> + <para> + In the XQuery/XPath data model, a <firstterm>document + node</firstterm> can have either document form (i.e., exactly one + top-level element, with only comments and processing instructions + outside of it) or content form (with those constraints + relaxed). Its equivalent in XPath 1.0, the + <firstterm>root node</firstterm>, can only be in document form. + This is part of the reason an <type>xml</type> value passed as the + context item to any <productname>PostgreSQL</productname> + XPath-based function must be in document form. + </para> + </listitem> + </itemizedlist> + </para> + + <para> + The differences highlighted here are not all of them. In XQuery and + the 2.0 and later versions of XPath, there is an XPath 1.0 compatibility + mode, and the W3C lists of + <ulink url='https://www.w3.org/TR/2010/REC-xpath-functions-20101214/#xpath1-compatibility'>function library changes</ulink> + and + <ulink url='https://www.w3.org/TR/xpath20/#id-backwards-compatibility'>language changes</ulink> + applied in that mode offer a more complete (but still not exhaustive) + account of the differences. The compatibility mode cannot make the + later languages exactly equivalent to XPath 1.0. + </para> + </sect3> + + <sect3 id="functions-xml-limits-casts"> + <title>Mappings between SQL and XML data types and values</title> + + <para> + In SQL:2006 and later, both directions of conversion between standard SQL + data types and the XML Schema types are specified precisely. However, the + rules are expressed using the types and semantics of XQuery/XPath, and + have no direct application to the different data model of XPath 1.0. + </para> + + <para> + When <productname>PostgreSQL</productname> maps SQL data values to XML + (as in <function>xmlelement</function>), or XML to SQL (as in the output + columns of <function>xmltable</function>), except for a few cases + treated specially, <productname>PostgreSQL</productname> simply assumes + that the XML data type's XPath 1.0 string form will be valid as the + text-input form of the SQL datatype, and conversely. This rule has the + virtue of simplicity while producing, for many data types, results similar + to the mappings specified in the standard. In this release, + an explicit cast is needed if an <function>xmltable</function> column + expression produces a boolean or double value; see + <xref linkend="functions-xml-limits-postgresql"/>. + </para> + + <para> + Where interoperability with other systems is a concern, for some data + types, it may be necessary to use data type formatting functions (such + as those in <xref linkend="functions-formatting"/>) explicitly to + produce the standard mappings. + </para> + </sect3> + </sect2> + + <sect2 id="functions-xml-limits-postgresql"> + <title> + Incidental limits of the implementation + </title> + + <para> + This section concerns limits that are not inherent in the + <application>libxml2</application> library, but apply to the current + implementation in <productname>PostgreSQL</productname>. + </para> + + <sect3> + <title> + Cast needed for <function>xmltable</function> column + of boolean or double type + </title> + + <para> + An <function>xmltable</function> column expression evaluating to an XPath + boolean or number result will produce an <quote>unexpected XPath object + type</quote> error. The workaround is to rewrite the column expression to + be inside the XPath <function>string</function> function; + <productname>PostgreSQL</productname> will then assign the string value + successfully to an SQL output column of boolean or double type. + </para> + </sect3> + + <sect3> + <title> + Column path result or SQL result column of XML type + </title> + + <para> + In this release, a <function>xmltable</function> column expression + that evaluates to an XML node-set can be assigned to an SQL result + column of XML type, producing a concatenation of: for most types of + node in the node-set, a text node containing the XPath 1.0 + <firstterm>string-value</firstterm> of the node, but for an element node, + a copy of the node itself. Such a node-set may be assigned to an SQL + column of non-XML type only if the node-set has a single node, with the + string-value of most node types replaced with an empty string, the + string-value of an element node replaced with a concatenation of only its + direct text-node children (excluding those of descendants), and the + string-value of a text or attribute node being as defined in XPath 1.0. + An XPath string value assigned to a result column of XML type must be + parsable as XML. + </para> + + <para> + It is best not to develop code that relies on these behaviors, which have + little resemblance to the spec, and are changed in + <productname>PostgreSQL 12</productname>. + </para> + </sect3> + + <sect3> + <title>Only <literal>BY VALUE</literal> passing mechanism is supported</title> + + <para> + The SQL standard defines two <firstterm>passing mechanisms</firstterm> + that apply when passing an XML argument from SQL to an XML function or + receiving a result: <literal>BY REF</literal>, in which a particular XML + value retains its node identity, and <literal>BY VALUE</literal>, in which + the content of the XML is passed but node identity is not preserved. A + mechanism can be specified before a list of parameters, as the default + mechanism for all of them, or after any parameter, to override the + default. + </para> + + <para> + To illustrate the difference, if + <replaceable>x</replaceable> is an XML value, these two queries in + an SQL:2006 environment would produce true and false, respectively: + +<programlisting> +SELECT XMLQUERY('$a is $b' PASSING BY REF <replaceable>x</replaceable> AS a, <replaceable>x</replaceable> AS b NULL ON EMPTY); +SELECT XMLQUERY('$a is $b' PASSING BY VALUE <replaceable>x</replaceable> AS a, <replaceable>x</replaceable> AS b NULL ON EMPTY); +</programlisting> + </para> + + <para> + In this release, <productname>PostgreSQL</productname> will accept + <literal>BY REF</literal> in an + <function>XMLEXISTS</function> or <function>XMLTABLE</function> + construct, but will ignore it. The <type>xml</type> data type holds + a character-string serialized representation, so there is no node + identity to preserve, and passing is always effectively <literal>BY + VALUE</literal>. + </para> + </sect3> + + <sect3> + <title>Cannot pass named parameters to queries</title> + + <para> + The XPath-based functions support passing one parameter to serve as the + XPath expression's context item, but do not support passing additional + values to be available to the expression as named parameters. + </para> + </sect3> + + <sect3> + <title>No <type>XML(SEQUENCE)</type> type</title> + + <para> + The <productname>PostgreSQL</productname> <type>xml</type> data type + can only hold a value in <literal>DOCUMENT</literal> + or <literal>CONTENT</literal> form. An XQuery/XPath expression + context item must be a single XML node or atomic value, but XPath 1.0 + further restricts it to be only an XML node, and has no node type + allowing <literal>CONTENT</literal>. The upshot is that a + well-formed <literal>DOCUMENT</literal> is the only form of XML value + that <productname>PostgreSQL</productname> can supply as an XPath + context item. + </para> + </sect3> + </sect2> + </sect1> + </appendix> diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index cfa1e78..bec1b87 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -10045,16 +10045,25 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple <sect1 id="functions-xml"> + <title>XML Functions</title> + <indexterm> + <primary>XML Functions</primary> + </indexterm> + <para> The functions and function-like expressions described in this - section operate on values of type <type>xml</type>. Check <xref + section operate on values of type <type>xml</type>. See <xref linkend="datatype-xml"/> for information about the <type>xml</type> type. The function-like expressions <function>xmlparse</function> and <function>xmlserialize</function> for converting to and from - type <type>xml</type> are not repeated here. Use of most of these - functions requires the installation to have been built + type <type>xml</type> are documented there, not in this section. + </para> + + <para> + Use of most of these functions + requires <productname>PostgreSQL</productname> to have been built with <command>configure --with-libxml</command>. </para> @@ -10249,8 +10258,8 @@ SELECT xmlelement(name foo, xmlattributes('xyz' as bar), encoding, depending on the setting of the configuration parameter <xref linkend="guc-xmlbinary"/>. The particular behavior for individual data types is expected to evolve in order to align the - SQL and PostgreSQL data types with the XML Schema specification, - at which point a more precise description will appear. + PostgreSQL mappings with those specified in SQL:2006 and later, + as discussed in <xref linkend="functions-xml-limits-casts"/>. </para> </sect3> @@ -10492,10 +10501,13 @@ SELECT xmlagg(x) FROM (SELECT * FROM test ORDER BY y DESC) AS tab; </synopsis> <para> - The function <function>xmlexists</function> returns true if the - XPath expression in the first argument returns any nodes, and - false otherwise. (If either argument is null, the result is - null.) + The function <function>xmlexists</function> evaluates an XPath 1.0 + expression (the first argument), with the passed XML value as its context + item. The function returns false if the result of that evaluation + yields an empty node-set, true if it yields any other value. The + function returns null if any argument is null. A nonnull value + passed as the context item must be an XML document, not a content + fragment or any non-XML value. </para> <para> @@ -10511,14 +10523,14 @@ SELECT xmlexists('//town[text() = ''Toronto'']' PASSING BY REF '<towns><town>Tor </para> <para> - The <literal>BY REF</literal> clauses have no effect in - PostgreSQL, but are allowed for SQL conformance and compatibility - with other implementations. Per SQL standard, the - first <literal>BY REF</literal> is required, the second is - optional. Also note that the SQL standard specifies - the <function>xmlexists</function> construct to take an XQuery - expression as first argument, but PostgreSQL currently only - supports XPath, which is a subset of XQuery. + The <literal>BY REF</literal> clauses + are accepted in <productname>PostgreSQL</productname>, but are ignored, + as discussed in <xref linkend="functions-xml-limits-postgresql"/>. + In the SQL standard, the <function>xmlexists</function> function + evaluates an expression in the XML Query language, + but <productname>PostgreSQL</productname> allows only an XPath 1.0 + expression, as discussed in + <xref linkend="functions-xml-limits-xpath1"/>. </para> </sect3> @@ -10624,12 +10636,12 @@ SELECT xml_is_well_formed_document('<pg:foo xmlns:pg="http://postgresql.org/stuf </synopsis> <para> - The function <function>xpath</function> evaluates the XPath + The function <function>xpath</function> evaluates the XPath 1.0 expression <replaceable>xpath</replaceable> (a <type>text</type> value) against the XML value <replaceable>xml</replaceable>. It returns an array of XML values - corresponding to the node set produced by the XPath expression. - If the XPath expression returns a scalar value rather than a node set, + corresponding to the node-set produced by the XPath expression. + If the XPath expression returns a scalar value rather than a node-set, a single-element array is returned. </para> @@ -10691,9 +10703,10 @@ SELECT xpath('//mydefns:b/text()', '<a xmlns="http://example.com"><b>test</b></a <para> The function <function>xpath_exists</function> is a specialized form of the <function>xpath</function> function. Instead of returning the - individual XML values that satisfy the XPath, this function returns a - Boolean indicating whether the query was satisfied or not. This - function is equivalent to the standard <literal>XMLEXISTS</literal> predicate, + individual XML values that satisfy the XPath 1.0 expression, this function + returns a Boolean indicating whether the query was satisfied or not + (specifically, whether it produced any value other than an empty node-set). + This function is equivalent to the <literal>XMLEXISTS</literal> predicate, except that it also offers support for a namespace mapping argument. </para> @@ -10734,8 +10747,8 @@ SELECT xpath_exists('/my:a/text()', '<my:a xmlns:my="http://example.com">test</m <para> The <function>xmltable</function> function produces a table based - on the given XML value, an XPath filter to extract rows, and an - optional set of column definitions. + on the given XML value, an XPath filter to extract rows, and a + set of column definitions. </para> <para> @@ -10746,30 +10759,34 @@ SELECT xpath_exists('/my:a/text()', '<my:a xmlns:my="http://example.com">test</m </para> <para> - The required <replaceable>row_expression</replaceable> argument is an XPath - expression that is evaluated against the supplied XML document to - obtain an ordered sequence of XML nodes. This sequence is what - <function>xmltable</function> transforms into output rows. + The required <replaceable>row_expression</replaceable> argument is + an XPath 1.0 expression that is evaluated, passing the + <replaceable>document_expression</replaceable> as its context item, to + obtain a set of XML nodes. These nodes are what + <function>xmltable</function> transforms into output rows. No rows + will be produced if the <replaceable>document_expression</replaceable> + is null, nor if the <replaceable>row_expression</replaceable> produces + an empty node-set or any value other than a node-set. </para> <para> - <replaceable>document_expression</replaceable> provides the XML document to - operate on. - The <literal>BY REF</literal> clauses have no effect in PostgreSQL, - but are allowed for SQL conformance and compatibility with other - implementations. - The argument must be a well-formed XML document; fragments/forests - are not accepted. + <replaceable>document_expression</replaceable> provides the context + item for the <replaceable>row_expression</replaceable>. It must be a + well-formed XML document; fragments/forests are not accepted. + The <literal>BY REF</literal> clauses + are accepted but ignored, as discussed in + <xref linkend="functions-xml-limits-postgresql"/>. + In the SQL standard, the <function>xmltable</function> function + evaluates expressions in the XML Query language, + but <productname>PostgreSQL</productname> allows only XPath 1.0 + expressions, as discussed in + <xref linkend="functions-xml-limits-xpath1"/>. </para> <para> The mandatory <literal>COLUMNS</literal> clause specifies the list of columns in the output table. - If the <literal>COLUMNS</literal> clause is omitted, the rows in the result - set contain a single column of type <literal>xml</literal> containing the - data matched by <replaceable>row_expression</replaceable>. - If <literal>COLUMNS</literal> is specified, each entry describes a - single column. + Each entry describes a single column. See the syntax summary above for the format. The column name and type are required; the path, default and nullability clauses are optional. @@ -10777,48 +10794,57 @@ SELECT xpath_exists('/my:a/text()', '<my:a xmlns:my="http://example.com">test</m <para> A column marked <literal>FOR ORDINALITY</literal> will be populated - with row numbers matching the order in which the - output rows appeared in the original input XML document. + with row numbers, starting with 1, in the order of nodes retrieved from + the <replaceable>row_expression</replaceable>'s result node-set. At most one column may be marked <literal>FOR ORDINALITY</literal>. </para> + <note> + <para> + XPath 1.0 does not specify an order for nodes in a node-set, so code + that relies on a particular order of the results will be + implementation-dependent. Details can be found in + <xref linkend="xml-xpath-1-specifics"/>. + </para> + </note> + <para> - The <literal>column_expression</literal> for a column is an XPath expression - that is evaluated for each row, relative to the result of the - <replaceable>row_expression</replaceable>, to find the value of the column. - If no <literal>column_expression</literal> is given, then the column name - is used as an implicit path. + The <replaceable>column_expression</replaceable> for a column is an + XPath 1.0 expression that is evaluated for each row, with the current + node from the <replaceable>row_expression</replaceable> result as its + context item, to find the value of the column. If + no <replaceable>column_expression</replaceable> is given, then the + column name is used as an implicit path. </para> <para> - If a column's XPath expression returns multiple elements, an error - is raised. - If the expression matches an empty tag, the result is an - empty string (not <literal>NULL</literal>). - Any <literal>xsi:nil</literal> attributes are ignored. + If a column's XPath expression returns a non-XML value (limited to + string, boolean, or double in XPath 1.0) and the column has a + PostgreSQL type other than <type>xml</type>, the column will be set + as if by assigning the value's string representation to the PostgreSQL + type. In this release, an XPath boolean or double result must be explicitly + cast to string (that is, the XPath 1.0 <function>string</function> function + wrapped around the original column expression); + <productname>PostgreSQL</productname> can then successfully assign the + string to an SQL result column of boolean or double type. + These conversion rules differ from those of the SQL + standard, as discussed in <xref linkend="functions-xml-limits-casts"/>. </para> <para> - The text body of the XML matched by the <replaceable>column_expression</replaceable> - is used as the column value. Multiple <literal>text()</literal> nodes - within an element are concatenated in order. Any child elements, - processing instructions, and comments are ignored, but the text contents - of child elements are concatenated to the result. - Note that the whitespace-only <literal>text()</literal> node between two non-text - elements is preserved, and that leading whitespace on a <literal>text()</literal> - node is not flattened. + In this release, SQL result columns of <type>xml</type> type, or + column XPath expressions evaluating to an XML type, regardless of the + output column SQL type, are handled as described in + <xref linkend="functions-xml-limits-postgresql"/>; the behavior + changes significantly in <productname>PostgreSQL 12</productname>. </para> <para> - If the path expression does not match for a given row but - <replaceable>default_expression</replaceable> is specified, the value resulting - from evaluating that expression is used. - If no <literal>DEFAULT</literal> clause is given for the column, - the field will be set to <literal>NULL</literal>. - It is possible for a <replaceable>default_expression</replaceable> to reference - the value of output columns that appear prior to it in the column list, - so the default of one column may be based on the value of another - column. + If the path expression returns an empty node-set + (typically, when it does not match) + for a given row, the column will be set to <literal>NULL</literal>, unless + a <replaceable>default_expression</replaceable> is specified; then the + value resulting from evaluating that expression is used. </para> <para> @@ -10830,20 +10856,14 @@ SELECT xpath_exists('/my:a/text()', '<my:a xmlns:my="http://example.com">test</m </para> <para> - Unlike regular PostgreSQL functions, <replaceable>column_expression</replaceable> - and <replaceable>default_expression</replaceable> are not evaluated to a simple - value before calling the function. - <replaceable>column_expression</replaceable> is normally evaluated - exactly once per input row, and <replaceable>default_expression</replaceable> - is evaluated each time a default is needed for a field. - If the expression qualifies as stable or immutable the repeat + A <replaceable>default_expression</replaceable>, rather than being + evaluated immediately when <function>xmltable</function> is called, + is evaluated each time a default is needed for the column. + If the expression qualifies as stable or immutable, the repeat evaluation may be skipped. - Effectively <function>xmltable</function> behaves more like a subquery than a - function call. This means that you can usefully use volatile functions like - <function>nextval</function> in <replaceable>default_expression</replaceable>, and - <replaceable>column_expression</replaceable> may depend on other parts of the - XML document. + <function>nextval</function> in + <replaceable>default_expression</replaceable>. </para> <para> diff --git a/src/backend/catalog/sql_features.txt b/src/backend/catalog/sql_features.txt index aeb262a..915696e 100644 --- a/src/backend/catalog/sql_features.txt +++ b/src/backend/catalog/sql_features.txt @@ -593,7 +593,7 @@ X085 Predefined namespace prefixes NO X086 XML namespace declarations in XMLTable NO X090 XML document predicate YES X091 XML content predicate NO -X096 XMLExists NO XPath only +X096 XMLExists NO XPath 1.0 only X100 Host language support for XML: CONTENT option NO X101 Host language support for XML: DOCUMENT option NO X110 Host language support for XML: VARCHAR mapping NO @@ -661,11 +661,11 @@ X282 XMLValidate with CONTENT option NO X283 XMLValidate with SEQUENCE option NO X284 XMLValidate: NAMESPACE without ELEMENT clause NO X286 XMLValidate: NO NAMESPACE with ELEMENT clause NO -X300 XMLTable NO XPath only +X300 XMLTable NO XPath 1.0 only X301 XMLTable: derived column list option YES X302 XMLTable: ordinality column option YES X303 XMLTable: column default option YES -X304 XMLTable: passing a context item YES +X304 XMLTable: passing a context item YES must be XML DOCUMENT X305 XMLTable: initializing an XQuery variable NO X400 Name and identifier mapping YES X410 Alter column data type: XML type YES -- 2.7.3 --------------060806070207090601090509 Content-Type: text/x-patch; name="10.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="10.patch" ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v1 8/9] ci: Don't specify amount of memory @ 2023-08-08 00:31 Andres Freund <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Andres Freund @ 2023-08-08 00:31 UTC (permalink / raw) The number of CPUs is the cost-determining factor. Most instance types that run tests have more memory/core than what we specified, there's no real benefit in wasting that. --- .cirrus.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index ef825485826..a4d64955489 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -150,7 +150,6 @@ task: image: family/pg-ci-freebsd-13 platform: freebsd cpu: $CPUS - memory: 4G disk: 50 sysinfo_script: | @@ -292,7 +291,6 @@ task: image: family/pg-ci-bullseye platform: linux cpu: $CPUS - memory: 4G ccache_cache: folder: ${CCACHE_DIR} @@ -554,7 +552,6 @@ task: image: family/pg-ci-windows-ci-vs-2019 platform: windows cpu: $CPUS - memory: 4G setup_additional_packages_script: | REM choco install -y --no-progress ... @@ -604,7 +601,6 @@ task: image: family/pg-ci-windows-ci-mingw64 platform: windows cpu: $CPUS - memory: 4G env: TEST_JOBS: 4 # higher concurrency causes occasional failures -- 2.38.0 --uu4yojthqnm7ulmd-- ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v1 8/9] ci: Don't specify amount of memory @ 2023-08-08 00:31 Andres Freund <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Andres Freund @ 2023-08-08 00:31 UTC (permalink / raw) The number of CPUs is the cost-determining factor. Most instance types that run tests have more memory/core than what we specified, there's no real benefit in wasting that. --- .cirrus.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index ef825485826..a4d64955489 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -150,7 +150,6 @@ task: image: family/pg-ci-freebsd-13 platform: freebsd cpu: $CPUS - memory: 4G disk: 50 sysinfo_script: | @@ -292,7 +291,6 @@ task: image: family/pg-ci-bullseye platform: linux cpu: $CPUS - memory: 4G ccache_cache: folder: ${CCACHE_DIR} @@ -554,7 +552,6 @@ task: image: family/pg-ci-windows-ci-vs-2019 platform: windows cpu: $CPUS - memory: 4G setup_additional_packages_script: | REM choco install -y --no-progress ... @@ -604,7 +601,6 @@ task: image: family/pg-ci-windows-ci-mingw64 platform: windows cpu: $CPUS - memory: 4G env: TEST_JOBS: 4 # higher concurrency causes occasional failures -- 2.38.0 --uu4yojthqnm7ulmd-- ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 01/10] ci: Don't specify amount of memory @ 2023-08-08 00:31 Andres Freund <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Andres Freund @ 2023-08-08 00:31 UTC (permalink / raw) The number of CPUs is the cost-determining factor. Most instance types that run tests have more memory/core than what we specified, there's no real benefit in wasting that. Discussion: https://postgr.es/m/[email protected] Backpatch: 15-, where CI support was added --- .cirrus.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 727c434de40..9e84eb95be5 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -149,7 +149,6 @@ task: image: family/pg-ci-freebsd-13 platform: freebsd cpu: $CPUS - memory: 4G disk: 50 sysinfo_script: | @@ -291,7 +290,6 @@ task: image: family/pg-ci-bullseye platform: linux cpu: $CPUS - memory: 4G ccache_cache: folder: ${CCACHE_DIR} @@ -558,7 +556,6 @@ task: image: family/pg-ci-windows-ci-vs-2019 platform: windows cpu: $CPUS - memory: 4G setup_additional_packages_script: | REM choco install -y --no-progress ... @@ -606,7 +603,6 @@ task: image: family/pg-ci-windows-ci-mingw64 platform: windows cpu: $CPUS - memory: 4G env: TEST_JOBS: 4 # higher concurrency causes occasional failures -- 2.38.0 --uh2yukyzfvojbe2k Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0002-ci-Move-execution-method-of-tasks-into-yaml-templ.patch" ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v1 8/9] ci: Don't specify amount of memory @ 2023-08-08 00:31 Andres Freund <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Andres Freund @ 2023-08-08 00:31 UTC (permalink / raw) The number of CPUs is the cost-determining factor. Most instance types that run tests have more memory/core than what we specified, there's no real benefit in wasting that. --- .cirrus.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index ef825485826..a4d64955489 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -150,7 +150,6 @@ task: image: family/pg-ci-freebsd-13 platform: freebsd cpu: $CPUS - memory: 4G disk: 50 sysinfo_script: | @@ -292,7 +291,6 @@ task: image: family/pg-ci-bullseye platform: linux cpu: $CPUS - memory: 4G ccache_cache: folder: ${CCACHE_DIR} @@ -554,7 +552,6 @@ task: image: family/pg-ci-windows-ci-vs-2019 platform: windows cpu: $CPUS - memory: 4G setup_additional_packages_script: | REM choco install -y --no-progress ... @@ -604,7 +601,6 @@ task: image: family/pg-ci-windows-ci-mingw64 platform: windows cpu: $CPUS - memory: 4G env: TEST_JOBS: 4 # higher concurrency causes occasional failures -- 2.38.0 --uu4yojthqnm7ulmd-- ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 01/10] ci: Don't specify amount of memory @ 2023-08-08 00:31 Andres Freund <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Andres Freund @ 2023-08-08 00:31 UTC (permalink / raw) The number of CPUs is the cost-determining factor. Most instance types that run tests have more memory/core than what we specified, there's no real benefit in wasting that. Discussion: https://postgr.es/m/[email protected] Backpatch: 15-, where CI support was added --- .cirrus.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 727c434de40..9e84eb95be5 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -149,7 +149,6 @@ task: image: family/pg-ci-freebsd-13 platform: freebsd cpu: $CPUS - memory: 4G disk: 50 sysinfo_script: | @@ -291,7 +290,6 @@ task: image: family/pg-ci-bullseye platform: linux cpu: $CPUS - memory: 4G ccache_cache: folder: ${CCACHE_DIR} @@ -558,7 +556,6 @@ task: image: family/pg-ci-windows-ci-vs-2019 platform: windows cpu: $CPUS - memory: 4G setup_additional_packages_script: | REM choco install -y --no-progress ... @@ -606,7 +603,6 @@ task: image: family/pg-ci-windows-ci-mingw64 platform: windows cpu: $CPUS - memory: 4G env: TEST_JOBS: 4 # higher concurrency causes occasional failures -- 2.38.0 --uh2yukyzfvojbe2k Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0002-ci-Move-execution-method-of-tasks-into-yaml-templ.patch" ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v5 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --ZcI1PtyEAe3VcVeQ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v5-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v6 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- src/bin/psql/tab-complete.in.c | 46 +++---- 4 files changed, 27 insertions(+), 288 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index af3935b0078..ce99137c613 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index 46b9add0604..f4d842966bf 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1209,6 +1209,18 @@ Keywords_for_list_of_owner_roles, "PUBLIC" " FROM pg_catalog.pg_timezone_names() "\ " WHERE pg_catalog.quote_literal(pg_catalog.lower(name)) LIKE pg_catalog.lower('%s')" +#define Query_for_list_of_publications \ +"SELECT pubname "\ +" FROM pg_catalog.pg_publication "\ +" WHERE pubname LIKE '%s'" + +#define Query_for_list_of_subscriptions \ +"SELECT s.subname "\ +" FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d"\ +" WHERE s.subname LIKE '%s' "\ +" AND d.datname = pg_catalog.current_database() "\ +" AND s.subdbid = d.oid" + /* Privilege options shared between GRANT and REVOKE */ #define Privilege_options_of_grant_and_revoke \ "SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", "REFERENCES", "TRIGGER", \ @@ -1243,32 +1255,6 @@ Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \ #define Copy_to_options \ Copy_common_options, "FORCE_QUOTE", "FORCE_ARRAY" -/* - * These object types were introduced later than our support cutoff of - * server version 9.2. We use the VersionedQuery infrastructure so that - * we don't send certain-to-fail queries to older servers. - */ - -static const VersionedQuery Query_for_list_of_publications[] = { - {100000, - " SELECT pubname " - " FROM pg_catalog.pg_publication " - " WHERE pubname LIKE '%s'" - }, - {0, NULL} -}; - -static const VersionedQuery Query_for_list_of_subscriptions[] = { - {100000, - " SELECT s.subname " - " FROM pg_catalog.pg_subscription s, pg_catalog.pg_database d " - " WHERE s.subname LIKE '%s' " - " AND d.datname = pg_catalog.current_database() " - " AND s.subdbid = d.oid" - }, - {0, NULL} -}; - /* Known command-starting keywords. */ static const char *const sql_commands[] = { "ABORT", "ALTER", "ANALYZE", "BEGIN", "CALL", "CHECKPOINT", "CLOSE", "CLUSTER", @@ -1346,7 +1332,7 @@ static const pgsql_thing_t words_after_create[] = { {"POLICY", NULL, NULL, NULL}, {"PROCEDURE", NULL, NULL, Query_for_list_of_procedures}, {"PROPERTY GRAPH", NULL, NULL, &Query_for_list_of_propgraphs}, - {"PUBLICATION", NULL, Query_for_list_of_publications}, + {"PUBLICATION", Query_for_list_of_publications}, {"ROLE", Query_for_list_of_roles}, {"ROUTINE", NULL, NULL, &Query_for_list_of_routines, NULL, THING_NO_CREATE}, {"RULE", "SELECT rulename FROM pg_catalog.pg_rules WHERE rulename LIKE '%s'"}, @@ -1354,7 +1340,7 @@ static const pgsql_thing_t words_after_create[] = { {"SEQUENCE", NULL, NULL, &Query_for_list_of_sequences}, {"SERVER", Query_for_list_of_servers}, {"STATISTICS", NULL, NULL, &Query_for_list_of_statistics}, - {"SUBSCRIPTION", NULL, Query_for_list_of_subscriptions}, + {"SUBSCRIPTION", Query_for_list_of_subscriptions}, {"SYSTEM", NULL, NULL, NULL, NULL, THING_NO_CREATE | THING_NO_DROP}, {"TABLE", NULL, NULL, &Query_for_list_of_tables}, {"TABLESPACE", Query_for_list_of_tablespaces}, @@ -5701,9 +5687,9 @@ match_previous_words(int pattern_id, else if (TailMatchesCS("\\dP*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_partitioned_relations); else if (TailMatchesCS("\\dRp*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_publications); + COMPLETE_WITH_QUERY(Query_for_list_of_publications); else if (TailMatchesCS("\\dRs*")) - COMPLETE_WITH_VERSIONED_QUERY(Query_for_list_of_subscriptions); + COMPLETE_WITH_QUERY(Query_for_list_of_subscriptions); else if (TailMatchesCS("\\ds*")) COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences); else if (TailMatchesCS("\\dt*")) -- 2.50.1 (Apple Git-155) --aHl3HfeiUuO3zeNC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v6-0004-run-pgindent-and-pgperltidy.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v2 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +-- src/bin/psql/describe.c | 255 +-------------------------------- 3 files changed, 11 insertions(+), 269 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..76d299fb55c 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -98,20 +98,12 @@ describeAggregates(const char *pattern, bool verbose, bool showSystem) gettext_noop("Result data type"), gettext_noop("Argument data types")); - if (pset.sversion >= 110000) appendPQExpBuffer(&buf, " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" "FROM pg_catalog.pg_proc p\n" " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" "WHERE p.prokind = " CppAsString2(PROKIND_AGGREGATE) "\n", gettext_noop("Description")); - else - appendPQExpBuffer(&buf, - " pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"\n" - "FROM pg_catalog.pg_proc p\n" - " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n" - "WHERE p.proisagg\n", - gettext_noop("Description")); if (!showSystem && !pattern) appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n" @@ -154,16 +146,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +294,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +379,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +591,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1078,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1604,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1621,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1648,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1667,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1688,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1905,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2059,14 +1916,11 @@ describeOneTableDetails(const char *schemaname, if (tableinfo.relkind == RELKIND_INDEX || tableinfo.relkind == RELKIND_PARTITIONED_INDEX) { - if (pset.sversion >= 110000) - { appendPQExpBuffer(&buf, ",\n CASE WHEN a.attnum <= (SELECT i.indnkeyatts FROM pg_catalog.pg_index i WHERE i.indexrelid = '%s') THEN '%s' ELSE '%s' END AS is_key", oid, gettext_noop("yes"), gettext_noop("no")); isindexkey_col = cols++; - } appendPQExpBufferStr(&buf, ",\n pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, TRUE) AS indexdef"); indexdef_col = cols++; } @@ -2461,10 +2315,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2420,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2671,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2746,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2848,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3014,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3123,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3544,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3554,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3794,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3849,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4339,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4846,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4915,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5144,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5152,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6475,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6612,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6862,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --CT89ko5pLUrsvFtH Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v3 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 493400f9090..c9573d4b765 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6272,15 +6272,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6291,19 +6289,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index e1449654f96..9f26ed928cb 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --6vzYk1swa63ey9i6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v3-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
* [PATCH v4 3/4] psql: bump minimum supported version to v10 @ 2026-04-17 18:34 Nathan Bossart <[email protected]> 0 siblings, 0 replies; 387+ messages in thread From: Nathan Bossart @ 2026-04-17 18:34 UTC (permalink / raw) --- doc/src/sgml/ref/psql-ref.sgml | 2 +- src/bin/psql/command.c | 23 +--- src/bin/psql/describe.c | 244 +-------------------------------- 3 files changed, 11 insertions(+), 258 deletions(-) diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 7c05afd4719..56c2692e618 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -5523,7 +5523,7 @@ PSQL_EDITOR_LINENUMBER_ARG='--line ' or an older major version. Backslash commands are particularly likely to fail if the server is of a newer version than <application>psql</application> itself. However, backslash commands of the <literal>\d</literal> family should - work with servers of versions back to 9.2, though not necessarily with + work with servers of versions back to 10, though not necessarily with servers newer than <application>psql</application> itself. The general functionality of running SQL commands and displaying query results should also work with servers of a newer major version, but this cannot diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index 01b8f11aadd..44ef11d980e 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -4471,10 +4471,10 @@ connection_warnings(bool in_startup) /* * Warn if server's major version is newer than ours, or if server - * predates our support cutoff (currently 9.2). + * predates our support cutoff (currently 10). */ if (pset.sversion / 100 > client_ver / 100 || - pset.sversion < 90200) + pset.sversion < 100000) printf(_("WARNING: %s major version %s, server major version %s.\n" " Some psql features might not work.\n"), pset.progname, @@ -6278,15 +6278,13 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, * ensure the right view gets replaced. Also, check relation kind * to be sure it's a view. * - * Starting with PG 9.4, views may have WITH [LOCAL|CASCADED] + * Views may have WITH [LOCAL|CASCADED] * CHECK OPTION. These are not part of the view definition * returned by pg_get_viewdef() and so need to be retrieved - * separately. Materialized views (introduced in 9.3) may have + * separately. Materialized views may have * arbitrary storage parameter reloptions. */ printfPQExpBuffer(query, "/* %s */\n", _("Get view's definition and details")); - if (pset.sversion >= 90400) - { appendPQExpBuffer(query, "SELECT nspname, relname, relkind, " "pg_catalog.pg_get_viewdef(c.oid, true), " @@ -6297,19 +6295,6 @@ get_create_object_cmd(EditableObjectType obj_type, Oid oid, "LEFT JOIN pg_catalog.pg_namespace n " "ON c.relnamespace = n.oid WHERE c.oid = %u", oid); - } - else - { - appendPQExpBuffer(query, - "SELECT nspname, relname, relkind, " - "pg_catalog.pg_get_viewdef(c.oid, true), " - "c.reloptions AS reloptions, " - "NULL AS checkoption " - "FROM pg_catalog.pg_class c " - "LEFT JOIN pg_catalog.pg_namespace n " - "ON c.relnamespace = n.oid WHERE c.oid = %u", - oid); - } break; } diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 7f9b2b71a36..ec9c61ee924 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -3,9 +3,9 @@ * * Support for the various \d ("describe") commands. Note that the current * expectation is that all functions in this file will succeed when working - * with servers of versions 9.2 and up. It's okay to omit irrelevant + * with servers of versions 10 and up. It's okay to omit irrelevant * information for an old server, but not to fail outright. (But failing - * against a pre-9.2 server is allowed.) + * against a pre-10 server is allowed.) * * Copyright (c) 2000-2026, PostgreSQL Global Development Group * @@ -154,16 +154,6 @@ describeAccessMethods(const char *pattern, bool verbose) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, true, false, false}; - if (pset.sversion < 90600) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support access methods.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching access methods")); @@ -312,9 +302,6 @@ describeFunctions(const char *functypes, const char *func_pattern, printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, true, true, true, false, true, true, false, false, false, false}; - /* No "Parallel" column before 9.6 */ - static const bool translate_columns_pre_96[] = {false, false, false, false, true, true, false, true, true, false, false, false, false}; - if (strlen(functypes) != strspn(functypes, df_options)) { pg_log_error("\\df only takes [%s] as options", df_options); @@ -400,7 +387,6 @@ describeFunctions(const char *functypes, const char *func_pattern, gettext_noop("stable"), gettext_noop("volatile"), gettext_noop("Volatility")); - if (pset.sversion >= 90600) appendPQExpBuffer(&buf, ",\n CASE\n" " WHEN p.proparallel = " @@ -613,16 +599,8 @@ describeFunctions(const char *functypes, const char *func_pattern, myopt.title = _("List of functions"); myopt.translate_header = true; - if (pset.sversion >= 90600) - { myopt.translate_columns = translate_columns; myopt.n_translate_columns = lengthof(translate_columns); - } - else - { - myopt.translate_columns = translate_columns_pre_96; - myopt.n_translate_columns = lengthof(translate_columns_pre_96); - } printQuery(res, &myopt, pset.queryFout, false, pset.logfile); @@ -1108,38 +1086,6 @@ permissionsList(const char *pattern, bool showSystem) " ), E'\\n') AS \"%s\"", gettext_noop("Column privileges")); - if (pset.sversion >= 90500 && pset.sversion < 100000) - appendPQExpBuffer(&buf, - ",\n pg_catalog.array_to_string(ARRAY(\n" - " SELECT polname\n" - " || CASE WHEN polcmd != '*' THEN\n" - " E' (' || polcmd::pg_catalog.text || E'):'\n" - " ELSE E':'\n" - " END\n" - " || CASE WHEN polqual IS NOT NULL THEN\n" - " E'\\n (u): ' || pg_catalog.pg_get_expr(polqual, polrelid)\n" - " ELSE E''\n" - " END\n" - " || CASE WHEN polwithcheck IS NOT NULL THEN\n" - " E'\\n (c): ' || pg_catalog.pg_get_expr(polwithcheck, polrelid)\n" - " ELSE E''\n" - " END" - " || CASE WHEN polroles <> '{0}' THEN\n" - " E'\\n to: ' || pg_catalog.array_to_string(\n" - " ARRAY(\n" - " SELECT rolname\n" - " FROM pg_catalog.pg_roles\n" - " WHERE oid = ANY (polroles)\n" - " ORDER BY 1\n" - " ), E', ')\n" - " ELSE E''\n" - " END\n" - " FROM pg_catalog.pg_policy pol\n" - " WHERE polrelid = c.oid), E'\\n')\n" - " AS \"%s\"", - gettext_noop("Policies")); - - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, ",\n pg_catalog.array_to_string(ARRAY(\n" " SELECT polname\n" @@ -1666,7 +1612,7 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 100000) + else { appendPQExpBuffer(&buf, "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " @@ -1683,57 +1629,6 @@ describeOneTableDetails(const char *schemaname, : "''"), oid); } - else if (pset.sversion >= 90500) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, c.relrowsecurity, c.relforcerowsecurity, " - "c.relhasoids, false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else if (pset.sversion >= 90400) - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence, c.relreplident\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT c.relchecks, c.relkind, c.relhasindex, c.relhasrules, " - "c.relhastriggers, false, false, c.relhasoids, " - "false as relispartition, %s, c.reltablespace, " - "CASE WHEN c.reloftype = 0 THEN '' ELSE c.reloftype::pg_catalog.regtype::pg_catalog.text END, " - "c.relpersistence\n" - "FROM pg_catalog.pg_class c\n " - "LEFT JOIN pg_catalog.pg_class tc ON (c.reltoastrelid = tc.oid)\n" - "WHERE c.oid = '%s';", - (verbose ? - "pg_catalog.array_to_string(c.reloptions || " - "array(select 'toast.' || x from pg_catalog.unnest(tc.reloptions) x), ', ')\n" - : "''"), - oid); - } res = PSQLexec(buf.data); if (!res) @@ -1761,8 +1656,7 @@ describeOneTableDetails(const char *schemaname, tableinfo.reloftype = (strcmp(PQgetvalue(res, 0, 11), "") != 0) ? pg_strdup(PQgetvalue(res, 0, 11)) : NULL; tableinfo.relpersistence = *(PQgetvalue(res, 0, 12)); - tableinfo.relreplident = (pset.sversion >= 90400) ? - *(PQgetvalue(res, 0, 13)) : 'd'; + tableinfo.relreplident = *(PQgetvalue(res, 0, 13)); if (pset.sversion >= 120000) tableinfo.relam = PQgetisnull(res, 0, 14) ? NULL : pg_strdup(PQgetvalue(res, 0, 14)); @@ -1781,8 +1675,6 @@ describeOneTableDetails(const char *schemaname, char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get sequence information")); - if (pset.sversion >= 100000) - { appendPQExpBuffer(&buf, "SELECT pg_catalog.format_type(seqtypid, NULL) AS \"%s\",\n" " seqstart AS \"%s\",\n" @@ -1804,30 +1696,6 @@ describeOneTableDetails(const char *schemaname, "FROM pg_catalog.pg_sequence\n" "WHERE seqrelid = '%s';", oid); - } - else - { - appendPQExpBuffer(&buf, - "SELECT 'bigint' AS \"%s\",\n" - " start_value AS \"%s\",\n" - " min_value AS \"%s\",\n" - " max_value AS \"%s\",\n" - " increment_by AS \"%s\",\n" - " CASE WHEN is_cycled THEN '%s' ELSE '%s' END AS \"%s\",\n" - " cache_value AS \"%s\"\n", - gettext_noop("Type"), - gettext_noop("Start"), - gettext_noop("Minimum"), - gettext_noop("Maximum"), - gettext_noop("Increment"), - gettext_noop("yes"), - gettext_noop("no"), - gettext_noop("Cycles?"), - gettext_noop("Cache")); - appendPQExpBuffer(&buf, "FROM %s", fmtId(schemaname)); - /* must be separate because fmtId isn't reentrant */ - appendPQExpBuffer(&buf, ".%s;", fmtId(relationname)); - } res = PSQLexec(buf.data); if (!res) @@ -2045,10 +1913,7 @@ describeOneTableDetails(const char *schemaname, appendPQExpBufferStr(&buf, ",\n (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t\n" " WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation"); attcoll_col = cols++; - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, ",\n a.attidentity"); - else - appendPQExpBufferStr(&buf, ",\n ''::pg_catalog.char AS attidentity"); attidentity_col = cols++; if (pset.sversion >= 120000) appendPQExpBufferStr(&buf, ",\n a.attgenerated"); @@ -2461,10 +2326,7 @@ describeOneTableDetails(const char *schemaname, CppAsString2(CONSTRAINT_EXCLUSION) ") AND " "condeferred) AS condeferred,\n"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, "i.indisreplident,\n"); - else - appendPQExpBufferStr(&buf, "false AS indisreplident,\n"); if (pset.sversion >= 150000) appendPQExpBufferStr(&buf, "i.indnullsnotdistinct,\n"); @@ -2569,10 +2431,7 @@ describeOneTableDetails(const char *schemaname, "pg_catalog.pg_get_indexdef(i.indexrelid, 0, true),\n " "pg_catalog.pg_get_constraintdef(con.oid, true), " "contype, condeferrable, condeferred"); - if (pset.sversion >= 90400) appendPQExpBufferStr(&buf, ", i.indisreplident"); - else - appendPQExpBufferStr(&buf, ", false AS indisreplident"); appendPQExpBufferStr(&buf, ", c2.reltablespace"); if (pset.sversion >= 180000) appendPQExpBufferStr(&buf, ", con.conperiod"); @@ -2823,17 +2682,11 @@ describeOneTableDetails(const char *schemaname, PQclear(result); /* print any row-level policies */ - if (pset.sversion >= 90500) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get row-level policies for this table")); appendPQExpBufferStr(&buf, "SELECT pol.polname,"); - if (pset.sversion >= 100000) appendPQExpBufferStr(&buf, " pol.polpermissive,\n"); - else - appendPQExpBufferStr(&buf, - " 't' as polpermissive,\n"); appendPQExpBuffer(&buf, " CASE WHEN pol.polroles = '{0}' THEN NULL ELSE pg_catalog.array_to_string(array(select rolname from pg_catalog.pg_roles where oid = any (pol.polroles) order by 1),',') END,\n" " pg_catalog.pg_get_expr(pol.polqual, pol.polrelid),\n" @@ -2904,7 +2757,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* print any extended statistics */ if (pset.sversion >= 140000) @@ -3007,7 +2859,7 @@ describeOneTableDetails(const char *schemaname, } PQclear(result); } - else if (pset.sversion >= 100000) + else { printfPQExpBuffer(&buf, "/* %s */\n", _("Get extended statistics for this table")); @@ -3173,8 +3025,6 @@ describeOneTableDetails(const char *schemaname, } /* print any publications */ - if (pset.sversion >= 100000) - { printfPQExpBuffer(&buf, "/* %s */\n", _("Get publications that publish this table")); if (pset.sversion >= 150000) @@ -3284,7 +3134,6 @@ describeOneTableDetails(const char *schemaname, printTableAddFooter(&cont, buf.data); } PQclear(result); - } /* Print publications where the table is in the EXCEPT clause */ if (pset.sversion >= 190000) @@ -3706,7 +3555,7 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else if (pset.sversion >= 100000) + else appendPQExpBuffer(&buf, "SELECT c.oid::pg_catalog.regclass, c.relkind," " false AS inhdetachpending," @@ -3716,14 +3565,6 @@ describeOneTableDetails(const char *schemaname, "ORDER BY pg_catalog.pg_get_expr(c.relpartbound, c.oid) = 'DEFAULT'," " c.oid::pg_catalog.regclass::pg_catalog.text;", oid); - else - appendPQExpBuffer(&buf, - "SELECT c.oid::pg_catalog.regclass, c.relkind," - " false AS inhdetachpending, NULL\n" - "FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i\n" - "WHERE c.oid = i.inhrelid AND i.inhparent = '%s'\n" - "ORDER BY c.oid::pg_catalog.regclass::pg_catalog.text;", - oid); result = PSQLexec(buf.data); if (!result) @@ -3964,11 +3805,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) ncols++; } appendPQExpBufferStr(&buf, "\n, r.rolreplication"); - - if (pset.sversion >= 90500) - { appendPQExpBufferStr(&buf, "\n, r.rolbypassrls"); - } appendPQExpBufferStr(&buf, "\nFROM pg_catalog.pg_roles r\n"); @@ -4023,7 +3860,6 @@ describeRoles(const char *pattern, bool verbose, bool showSystem) if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) add_role_attribute(&buf, _("Replication")); - if (pset.sversion >= 90500) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0) add_role_attribute(&buf, _("Bypass RLS")); @@ -4514,19 +4350,6 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) const char *tabletitle; bool mixed_output = false; - /* - * Note: Declarative table partitioning is only supported as of Pg 10.0. - */ - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support declarative table partitioning.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - /* If no relation kind was selected, show them all */ if (!showTables && !showIndexes) showTables = showIndexes = true; @@ -5034,16 +4857,6 @@ listEventTriggers(const char *pattern, bool verbose) static const bool translate_columns[] = {false, false, false, true, false, false, false}; - if (pset.sversion < 90300) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support event triggers.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching event triggers")); @@ -5113,16 +4926,6 @@ listExtendedStats(const char *pattern, bool verbose) PGresult *res; printQueryOpt myopt = pset.popt; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support extended statistics.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching extended statistics")); @@ -5352,7 +5155,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) gettext_noop("Schema"), gettext_noop("Name")); - if (pset.sversion >= 100000) appendPQExpBuffer(&buf, " CASE c.collprovider " "WHEN " CppAsString2(COLLPROVIDER_DEFAULT) " THEN 'default' " @@ -5361,10 +5163,6 @@ listCollations(const char *pattern, bool verbose, bool showSystem) "WHEN " CppAsString2(COLLPROVIDER_ICU) " THEN 'icu' " "END AS \"%s\",\n", gettext_noop("Provider")); - else - appendPQExpBuffer(&buf, - " 'libc' AS \"%s\",\n", - gettext_noop("Provider")); appendPQExpBuffer(&buf, " c.collcollate AS \"%s\",\n" @@ -6688,16 +6486,6 @@ listPublications(const char *pattern) printQueryOpt myopt = pset.popt; static const bool translate_columns[] = {false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching publications")); @@ -6835,16 +6623,6 @@ describePublications(const char *pattern) PQExpBufferData title; printTableContent cont; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support publications.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - has_pubsequence = (pset.sversion >= 190000); has_pubtruncate = (pset.sversion >= 110000); has_pubgencols = (pset.sversion >= 180000); @@ -7095,16 +6873,6 @@ describeSubscriptions(const char *pattern, bool verbose) false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}; - if (pset.sversion < 100000) - { - char sverbuf[32]; - - pg_log_error("The server (version %s) does not support subscriptions.", - formatPGVersionNumber(pset.sversion, false, - sverbuf, sizeof(sverbuf))); - return true; - } - initPQExpBuffer(&buf); printfPQExpBuffer(&buf, "/* %s */\n", _("Get matching subscriptions")); -- 2.50.1 (Apple Git-155) --2xrO7hiVfr8aWtYg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v4-0004-run-pgindent.patch ^ permalink raw reply [nested|flat] 387+ messages in thread
end of thread, other threads:[~2026-04-17 18:34 UTC | newest] Thread overview: 387+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-07-09 11:36 [PATCH 4/4] add force_incremental_sort GUC Tomas Vondra <[email protected]> 2019-08-03 02:47 [PATCH] Improve documentation about our XML functionality. nobody <[email protected]> 2023-08-08 00:31 [PATCH v3 01/10] ci: Don't specify amount of memory Andres Freund <[email protected]> 2023-08-08 00:31 [PATCH v3 01/10] ci: Don't specify amount of memory Andres Freund <[email protected]> 2023-08-08 00:31 [PATCH v1 8/9] ci: Don't specify amount of memory Andres Freund <[email protected]> 2023-08-08 00:31 [PATCH v1 8/9] ci: Don't specify amount of memory Andres Freund <[email protected]> 2023-08-08 00:31 [PATCH v1 8/9] ci: Don't specify amount of memory Andres Freund <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v6 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v4 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v5 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v2 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]> 2026-04-17 18:34 [PATCH v3 3/4] psql: bump minimum supported version to v10 Nathan Bossart <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox