This topic describes the changes after upgrading from PolarDB for PostgreSQL 11 to PolarDB for PostgreSQL 14.
Overview
PolarDB for PostgreSQL is an enterprise-grade relational database management system with wide adoption and strong community support. Each new major version introduces numerous improvements and features to enhance performance, usability, and security. Upgrading to PolarDB for PostgreSQL 14 significantly improves database performance and user experience.
PolarDB for PostgreSQL 14 introduces new query optimization algorithms and storage engine enhancements that improve query speed and concurrent processing. This allows the database to handle large data volumes more quickly, increasing responsiveness and overall performance. This version also adds many new and enhanced features to provide a better user experience and more powerful developer tools. For example, it improves support for the JSON data type to simplify data processing and queries, provides richer monitoring and diagnostic tools to help you understand and optimize database performance, and strengthens security and reliability with a stricter access control policy and permission management features to protect your data from potential threats. It also includes improved backup and recovery, making data protection and restoration easier.
Upgrading to PolarDB for PostgreSQL 14 also means you stay current with the PostgreSQL community, which provides more resources and support to help you solve problems and learn database best practices. We recommend that you upgrade to PolarDB for PostgreSQL 14.
During an upgrade from PolarDB for PostgreSQL 11 to PolarDB for PostgreSQL 14, most data types, built-in functions, table columns, and objects do not change significantly, with most modifications being minor improvements. You can achieve nearly 100% compatibility by using methods like logical replication. We recommend using DTS for this purpose. The following sections detail the specific changes.
System tables and built-in columns
Removes the special behavior of the oid column. In version 11, you could use
WITH OIDSduring table creation to specify a normally invisible oid column. Version 14 removes this capability. However, you can still explicitly declare a column with the oid data type. Operations on columns created withWITH OIDSmust be adjusted. The hiddenoidcolumns in system catalogs are now regular columns. As a result,SELECT *now outputs these columns, whereas in previous versions, they were displayed only when explicitly selected.Table columns of the
nametype are now marked with theCcollation by default. Comparison operators for thenamedata type can now use any collation, not just theCcollation. To maintain the previous query semantics, table columns of typenameare now explicitly marked as having theCcollation. A side effect of this change is that regular expression operators onnamecolumns now use theCcollation by default, instead of the database's collation, to determine the behavior of locale-dependent regular expression patterns like\w. If you want to use non-Cbehavior for a regular expression on anamecolumn, append an explicitCOLLATEclause. For user-definednamecolumns, another option is to specify a different collation during table creation, but this only shifts the backward incompatibility to the comparison operators.Treats object name columns in
information_schemaviews as typenameinstead ofvarchar. According to the SQL standard, object name columns ininformation_schemaviews are declared with thedomaintypesql_identifier. In PostgreSQL, the underlying catalog columns are actually of typename. This change makessql_identifieradomainovernameinstead ofvarchar. This eliminates semantic mismatches in comparison and sorting behavior and can greatly improve the performance of queries oninformation_schemaviews that filter on object name columns.NoteFor inequality restrictions, such as
SELECT ... FROM information_schema.tables WHERE table_name < 'foo';, the query now uses the comparison semantics of theClocale by default, instead of the database's default collation. Sorting these columns will also follow theCcollation. You can add aCOLLATE "default"clause to force the previous behavior and its associated inefficiency.Removes the obsolete
pg_constraint.consrccolumn. This column had long been deprecated because it was not updated to reflect other catalog changes, such as column renames. The recommended way to get the text of a check constraint expression frompg_constraintispg_get_expr(conbin, conrelid). Thepg_get_constraintdef()function is also a useful alternative.Removes the obsolete
pg_attrdef.adsrccolumn. This column had long been deprecated because it was not updated to reflect other catalog changes, such as column renames. The recommended way to get the text of a default-value expression frompg_attrdefispg_get_expr(adbin, adrelid).
Operators and regular expressions
Removes the factorial operators
!and!!, and thenumeric_fac( )function. Thefactorial()function is still supported.Removes support for postfix (right-unary) operators. If you are dumping a postfix operator,
pg_dumpandpg_upgradewill issue a warning.Prevents the containment operators (
<@and@>) forintarrayfrom using a GiST index. A heap scan is now faster than a full GiST index scan. You should drop any indexes created for this purpose.Refactors the code for geometric functions and operators. This may lead to more accurate but slightly different results compared to version 11.
NoteCases involving NaN, underflow, overflow, and division by zero are now handled more consistently.
Allows the
\Dand\Wwildcards to match newlines in newline-sensitive regular expression modes. Previously, they did not match newlines in this mode, which was inconsistent with the behavior of other common regular expression engines. You can use[^[:digit:]]or[^[:word:]]to restore the old behavior.Ignores constraints when matching a regular expression back-reference. For example, in
(^\d+).*\1, the^constraint should be applied at the beginning of the string, but not when matching\1.Disallows
\was the start or end of a range in a regular expression character class.
Functions and expressions
The
factorialfunction no longer accepts negative numbers. In version 11, it returned 1 for such cases.Improves the output performance of
realanddouble precisionvalues by using a new algorithm. In version 11, floating-point values were rounded to 6 digits (forreal) or 15 digits (fordouble precision) by default, adjusted by the value ofextra_float_digits. In version 14, ifextra_float_digitsis greater than zero (the default), the output includes only the minimum number of digits required to preserve the exact binary value. Whenextra_float_digitsis set to zero or less, the behavior is the same as in version 11. In addition, the format of floating-point exponents is now consistent across all platforms: a two-digit exponent is used unless a three-digit one is required.When the input is a single NaN value,
var_samp()andstddev_samp()fornumerictypes now return NULL. In version 11, these functions returned NaN.The behavior of
random()andsetseed()is now consistent across all platforms, which was not the case in version 11. The sequence ofrandom()values generated after asetseed()call with a specific seed value may differ from the sequence in version 11. However, the sequence is now repeatable, which was not guaranteed in version 11 because other uses of random numbers within the server could interfere. The SQLrandom()function now has its own private session state to prevent this.Changes the return type of
EXTRACT()fromfloat8tonumeric. This avoids precision loss issues in some use cases. You can obtain the old behavior by using thedate_part()function. In addition, in version 14,EXTRACT(date)throws an error for units that are not applicable to thedatedata type.Changes the SQL-style
substring()to have standard-compliant greedy behavior. In cases where a pattern can match in multiple ways, version 14 matches the longest possible initial sub-pattern. For example, the pattern%#"aa*#"will select the last group ofa's in the input, not the first.You must recreate user-defined objects that reference certain built-in array functions and their argument types. Specifically,
array_append(),array_prepend(),array_cat(),array_position(),array_positions(),array_remove(),array_replace(), andwidth_bucket()acceptedanyarrayarguments in version 11 but acceptanycompatiblearrayin version 14. Therefore, user-defined objects like aggregates and operators that reference the signatures of these array functions must be dropped before an upgrade and recreated after the upgrade is complete.has_column_privilege()now returnsfalsefor checks on non-existent or dropped columns that use an attribute number. In version 11, such attribute numbers would return an invalid-column error.Fixes
to_tsquery()andwebsearch_to_tsquery()to correctly parse query text containing discarded tokens. Some discarded tokens, such as underscores, caused these functions to produce incorrecttsqueryoutput. For example,websearch_to_tsquery('"pg_class pg"')andto_tsquery('pg_class <-> pg')both output( 'pg' & 'class' ) <-> 'pg'in version 11, but in version 14, both output'pg' <-> 'class' <-> 'pg'.Fixes
websearch_to_tsquery()to correctly parse quoted text with multiple adjacent discarded tokens. In version 11, quoted text containing multiple adjacent discarded tokens was treated as multiple tokens, resulting in incorrecttsqueryoutput. For example,websearch_to_tsquery('"aaa: bbb"')outputs'aaa' <2> 'bbb'in version 11 but outputs'aaa' <-> 'bbb'in version 14.Fixes the handling of infinite window function ranges. In version 11, window frame clauses like
'inf' PRECEDING AND 'inf' FOLLOWINGwould return incorrect results.Prevents the
tablefuncfunctionnormal_rand()from accepting negative values. Negative values produced undesirable results.Changes
SIMILAR TO ... ESCAPE NULLto return NULL. This new behavior complies with the SQL specification. In version 11, a nullESCAPEvalue was treated as using the default escape string (a backslash character). The same rule applies tosubstring(text FROM pattern ESCAPE text). The version 11 behavior is preserved in old views by leaving the original function unchanged.Makes
json[b]_to_tsvector()fully check the spelling of itsstringoption.Removes the
pretty-printeffect from the results ofxpath()orXMLTABLE. In some cases, these functions inserted extra whitespace (newlines and/or spaces) into node-set values. This behavior was removed because whitespace can be semantically significant depending on the use case.
Query optimization
Changes how non-default
effective_io_concurrencyvalues affect concurrency. In version 11, this value was adjusted before setting the number of concurrent requests, whereas version 14 uses the value directly. You can use the following method to convert an old value to the new equivalent:SELECT round(sum(OLDVALUE / n::float)) AS newvalue FROM generate_series(1, OLDVALUE) s(n);.In
ltree, when anlquerypattern contains adjacent asterisks in parentheses, such as*{2}.{3}, it is now correctly interpreted as{5}.In new B-tree indexes, the maximum length of an index entry is reduced by eight bytes to improve duplicate handling. This means that a
REINDEXoperation on an index from a version 11 database that has undergonepg_upgrademight fail.
DDL operations
Fixes
ALTER FOREIGN TABLE ... RENAME COLUMNto return a more appropriate command tag. In version 11, it returnedALTER TABLE. In version 14, it returnsALTER FOREIGN TABLE.Fixes
ALTER MATERIALIZED VIEW ... RENAME COLUMNto return a more appropriate command tag. In version 11, it returnedALTER TABLE. In version 14, it returnsALTER MATERIALIZED VIEW.Disallows single quotes around the language name in
CREATE/DROP LANGUAGEcommands.Using
DROP IF EXISTS FUNCTION/PROCEDURE/AGGREGATE/ROUTINEnow throws an error if no argument list is provided and multiple matching objects exist. The error messages for this situation have also been improved.
Extensions and tools
Disallows non-unique abbreviations in psql's
\pset formatcommand. In version 11, for example,\pset format aselectedaligned; in version 14, this fails because it could also representasciidoc.Removes the
timetravelextension and the data typesabstime,reltime, andtinterval. These types have long been superseded by SQL-standard types such astimestamp.Prevents auxiliary processes from appearing in the
pg_stat_sslandpg_stat_gssapisystem views. If your queries join these views withpg_stat_activityand you expect to see auxiliary processes, you must now use a left join.