|
35 | 35 | * Caller must have already checked privileges, and done consistency
|
36 | 36 | * checks on the given datatypes and cast function (if applicable).
|
37 | 37 | *
|
| 38 | + * Since we allow binary coercibility of the datatypes to the cast |
| 39 | + * function's input and result, there could be one or two WITHOUT FUNCTION |
| 40 | + * casts that this one depends on. We don't record that explicitly |
| 41 | + * in pg_cast, but we still need to make dependencies on those casts. |
| 42 | + * |
38 | 43 | * 'behavior' indicates the types of the dependencies that the new
|
39 |
| - * cast will have on its input and output types and the cast function. |
| 44 | + * cast will have on its input and output types, the cast function, |
| 45 | + * and the other casts if any. |
40 | 46 | * ----------------------------------------------------------------
|
41 | 47 | */
|
42 | 48 | ObjectAddress
|
43 |
| -CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, char castcontext, |
44 |
| - char castmethod, DependencyType behavior) |
| 49 | +CastCreate(Oid sourcetypeid, Oid targettypeid, |
| 50 | + Oid funcid, Oid incastid, Oid outcastid, |
| 51 | + char castcontext, char castmethod, DependencyType behavior) |
45 | 52 | {
|
46 | 53 | Relation relation;
|
47 | 54 | HeapTuple tuple;
|
@@ -102,6 +109,18 @@ CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, char castcontext,
|
102 | 109 | add_exact_object_address(&referenced, addrs);
|
103 | 110 | }
|
104 | 111 |
|
| 112 | + /* dependencies on casts required for function */ |
| 113 | + if (OidIsValid(incastid)) |
| 114 | + { |
| 115 | + ObjectAddressSet(referenced, CastRelationId, incastid); |
| 116 | + add_exact_object_address(&referenced, addrs); |
| 117 | + } |
| 118 | + if (OidIsValid(outcastid)) |
| 119 | + { |
| 120 | + ObjectAddressSet(referenced, CastRelationId, outcastid); |
| 121 | + add_exact_object_address(&referenced, addrs); |
| 122 | + } |
| 123 | + |
105 | 124 | record_object_address_dependencies(&myself, addrs, behavior);
|
106 | 125 | free_object_addresses(addrs);
|
107 | 126 |
|
|
0 commit comments