pgsql: Database-level collation version tracking

Started by Peter Eisentrautover 4 years ago3 messagescomitters
Jump to latest
#1Peter Eisentraut
peter_e@gmx.net

Database-level collation version tracking

This adds to database objects the same version tracking that collation
objects have. There is a new pg_database column datcollversion that
stores the version, a new function
pg_database_collation_actual_version() to get the version from the
operating system, and a new subcommand ALTER DATABASE ... REFRESH
COLLATION VERSION.

This was not originally added together with pg_collation.collversion,
since originally version tracking was only supported for ICU, and ICU
on a database-level is not currently supported. But we now have
version tracking for glibc (since PG13), FreeBSD (since PG14), and
Windows (since PG13), so this is useful to have now.

Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>
Discussion: /messages/by-id/f0ff3190-29a3-5b39-a179-fa32eee57db6@enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/37851a8b83d3d57ca48736093b10aa5f3bc0c177

Modified Files
--------------
doc/src/sgml/catalogs.sgml | 11 ++
doc/src/sgml/func.sgml | 18 +++
doc/src/sgml/ref/alter_collation.sgml | 3 +-
doc/src/sgml/ref/alter_database.sgml | 12 ++
doc/src/sgml/ref/create_database.sgml | 21 +++
src/backend/commands/dbcommands.c | 194 ++++++++++++++++++++++-
src/backend/parser/gram.y | 6 +
src/backend/tcop/utility.c | 14 +-
src/backend/utils/init/postinit.c | 34 ++++
src/bin/initdb/initdb.c | 12 ++
src/bin/pg_dump/pg_dump.c | 21 +++
src/bin/psql/tab-complete.c | 2 +-
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_database.h | 3 +
src/include/catalog/pg_proc.dat | 5 +
src/include/commands/dbcommands.h | 1 +
src/include/nodes/nodes.h | 1 +
src/include/nodes/parsenodes.h | 6 +
src/test/regress/expected/collate.icu.utf8.out | 4 +
src/test/regress/expected/collate.linux.utf8.out | 4 +
src/test/regress/sql/collate.icu.utf8.sql | 4 +
src/test/regress/sql/collate.linux.utf8.sql | 4 +
22 files changed, 367 insertions(+), 15 deletions(-)

#2Michael Paquier
michael@paquier.xyz
In reply to: Peter Eisentraut (#1)
Re: pgsql: Database-level collation version tracking

On Mon, Feb 14, 2022 at 07:40:22AM +0000, Peter Eisentraut wrote:

Database-level collation version tracking

This adds to database objects the same version tracking that collation
objects have. There is a new pg_database column datcollversion that
stores the version, a new function
pg_database_collation_actual_version() to get the version from the
operating system, and a new subcommand ALTER DATABASE ... REFRESH
COLLATION VERSION.

This was not originally added together with pg_collation.collversion,
since originally version tracking was only supported for ICU, and ICU
on a database-level is not currently supported. But we now have
version tracking for glibc (since PG13), FreeBSD (since PG14), and
Windows (since PG13), so this is useful to have now.

calliphoridae does not like this one:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=calliphoridae&amp;dt=2022-02-14%2007%3A41%3A13

 SELECT current_database() AS datname \\gset
 ALTER DATABASE :"datname" REFRESH COLLATION VERSION;
-NOTICE:  version has not changed
+ERROR:  unrecognized node type: 291

Worth noting that it uses -DDCOPY_PARSE_PLAN_TREES and
-DRAW_EXPRESSION_COVERAGE_TEST, so you may have missed a piece in this
area.
--
Michael

#3Peter Eisentraut
peter_e@gmx.net
In reply to: Michael Paquier (#2)
Re: pgsql: Database-level collation version tracking

On 14.02.22 09:18, Michael Paquier wrote:

calliphoridae does not like this one:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=calliphoridae&amp;dt=2022-02-14%2007%3A41%3A13

SELECT current_database() AS datname \\gset
ALTER DATABASE :"datname" REFRESH COLLATION VERSION;
-NOTICE:  version has not changed
+ERROR:  unrecognized node type: 291

Worth noting that it uses -DDCOPY_PARSE_PLAN_TREES and
-DRAW_EXPRESSION_COVERAGE_TEST, so you may have missed a piece in this
area.

Fun fact: You'd think that just copying "-DDCOPY_PARSE_PLAN_TREES
-DRAW_EXPRESSION_COVERAGE_TEST" into, say, COPT, would help debug this,
but that only works if the originals are spelled correctly. ;-)