forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb55f2b6
committed
Adjust pg_dump's priority ordering for casts.
When a stored expression depends on a user-defined cast, the backendrecords the dependency as being on the cast's implementation function--- or indeed, if there's no cast function involved but justRelabelType or CoerceViaIO, no dependency is recorded at all. Thisis problematic for pg_dump, which is at risk of dumping things in thewrong order leading to restore failures. Given the lack of previousreports, the risk isn't that high, but it can be demonstrated if thecast is used in some view whose rowtype is then used as an input orresult type for some other function. (That results in the viewgetting hoisted into the functions portion of the dump, ahead ofthe cast.)A logically bulletproof fix for this would require including thecast's OID in the parsed form of the expression, whence it could beextracted by dependency.c, and then the stored dependency would forcepg_dump to do the right thing. Such a change would be fairly invasive,and certainly not back-patchable. Moreover, since we'd prefer thatan expression using cast syntax be equal() to one doing the samething by explicit function call, the cast OID field would have tohave special ignored-by-comparisons semantics, making things messy.So, let's instead fix this by a very simple hack in pg_dump: changethe object-type priority order so that casts are initially sortedbefore functions, immediately after types. This fixes the problemin a fairly direct way for casts that have no implementation function.For those that do, the implementation function will be hoisted to justbefore the cast by the dependency sorting step, so that we still havea valid dump order. (I'm not sure that this provides a full guaranteeof no problems; but since it's been like this for many years withoutany previous reports, this is probably enough to fix it in practice.)Per report from Дмитрий Иванов.Back-patch to all supported branches.Discussion:https://postgr.es/m/CAPL5KHoGa3uvyKp6z6m48LwCnTsK+LRQ_mcA4uKGfqAVSEjV_A@mail.gmail.com1 parentdb3a660 commitb55f2b6
1 file changed
+10
-1
lines changedLines changed: 10 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
34 | 34 |
| |
35 | 35 |
| |
36 | 36 |
| |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
37 | 46 |
| |
38 | 47 |
| |
39 | 48 |
| |
| |||
49 | 58 |
| |
50 | 59 |
| |
51 | 60 |
| |
| 61 | + | |
52 | 62 |
| |
53 | 63 |
| |
54 | 64 |
| |
55 | 65 |
| |
56 | 66 |
| |
57 |
| - | |
58 | 67 |
| |
59 | 68 |
| |
60 | 69 |
| |
|
0 commit comments
Comments
(0)