pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Record dependencies of a cast on other casts that it requires.
Date: Mon, 17 Oct 2022 18:02:13 +0000
Message-ID: <E1okURJ-002naV-9q@gemulon.postgresql.org> (raw)

Record dependencies of a cast on other casts that it requires.

When creating a cast that uses a conversion function, we've
historically allowed the input and result types to be
binary-compatible with the function's input and result types,
rather than necessarily being identical.  This means that the new
cast is logically dependent on the binary-compatible cast or casts
that it references: if those are defined by pg_cast entries, and you
try to restore the new cast without having defined them, it'll fail.
Hence, we should make pg_depend entries to record these dependencies
so that pg_dump knows that there is an ordering requirement.

This is not the only place where we allow such shortcuts; aggregate
functions for example are similarly lax, and in principle should gain
similar dependencies.  However, for now it seems sufficient to fix
the cast-versus-cast case, as pg_dump's other ordering heuristics
should keep it out of trouble for other object types.

Per report from David TuroĊˆ; thanks also to Robert Haas for
preliminary investigation.  I considered back-patching, but
seeing that this issue has existed for many years without
previous reports, it's not clear it's worth the trouble.
Moreover, back-patching wouldn't be enough to ensure that the
new pg_depend entries exist in existing databases anyway.

Discussion: https://postgr.es/m/OF0A160F3E.578B15D1-ONC12588DA.003E4857-C12588DA.0045A428@notes.linuxbox.cz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8272749e8ca1dbbcb5f8cf5632ec26a573ac3111

Modified Files
--------------
src/backend/catalog/pg_cast.c             | 25 ++++++++++++++++++++++---
src/backend/commands/functioncmds.c       | 14 ++++++++++----
src/backend/commands/typecmds.c           |  4 +++-
src/backend/parser/parse_coerce.c         | 21 +++++++++++++++++++++
src/include/catalog/pg_cast.h             |  2 ++
src/include/parser/parse_coerce.h         |  2 ++
src/test/regress/expected/create_cast.out | 29 +++++++++++++++++++++++++++++
src/test/regress/sql/create_cast.sql      | 21 +++++++++++++++++++++
src/tools/valgrind.supp                   |  2 +-
9 files changed, 111 insertions(+), 9 deletions(-)



Message-ID: <E1okURJ-002naV-9q@gemulon.postgresql.org>
Permalink:  ../E1okURJ-002naV-9q@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1okURJ-002naV-9q@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Record dependencies of a cast on other casts that it requires.
  In-Reply-To: <E1okURJ-002naV-9q@gemulon.postgresql.org>
  References: <E1okURJ-002naV-9q@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox