diff options
| author | Tom Lane | 2022-10-17 18:02:05 +0000 |
|---|---|---|
| committer | Tom Lane | 2022-10-17 18:02:05 +0000 |
| commit | 8272749e8ca1dbbcb5f8cf5632ec26a573ac3111 (patch) | |
| tree | aeee7a1615af0d87b69db96f38d734e8d4782f70 /src/include | |
| parent | 797e313dc9aed83e28e9f1d08a281ea48c560cd2 (diff) | |
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
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/catalog/pg_cast.h | 2 | ||||
| -rw-r--r-- | src/include/parser/parse_coerce.h | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h index 3c15df00531..67b08a4663c 100644 --- a/src/include/catalog/pg_cast.h +++ b/src/include/catalog/pg_cast.h @@ -95,6 +95,8 @@ typedef enum CoercionMethod extern ObjectAddress CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, + Oid incastid, + Oid outcastid, char castcontext, char castmethod, DependencyType behavior); diff --git a/src/include/parser/parse_coerce.h b/src/include/parser/parse_coerce.h index b105c7da900..ddbc995077a 100644 --- a/src/include/parser/parse_coerce.h +++ b/src/include/parser/parse_coerce.h @@ -32,6 +32,8 @@ typedef enum CoercionPathType extern bool IsBinaryCoercible(Oid srctype, Oid targettype); +extern bool IsBinaryCoercibleWithCast(Oid srctype, Oid targettype, + Oid *castoid); extern bool IsPreferredType(TYPCATEGORY category, Oid type); extern TYPCATEGORY TypeCategory(Oid type); |
