forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit84c5e0d
committed
Fix pg_restore's misdesigned code for detecting archive file format.
Despite the clear comments pointing out that the duplicative codesegments in ReadHead() and _discoverArchiveFormat() needed to bein sync, they were not: the latter did not bother to apply any ofthe sanity checks in the former. We'd missed noticing this partlybecause none of those checks would fail in scenarios we customarilytest, and partly because the oversight would be masked if bothsegments execute, which they would in cases other than needing toautodetect the format of a non-seekable stdin source. However,in a case meeting all these requirements --- for example, tryingto read a newer-than-supported archive format from non-seekablestdin --- pg_restore missed applying the version check and wouldlikely dump core or otherwise misbehave.The whole thing is silly anyway, because there seems little reasonto duplicate the logic beyond the one-line verification that thefile starts with "PGDMP". There seems to have been an undocumentedassumption that multiple major formats (major enough to requireseparate reader modules) would nonetheless share the first half-dozenfields of the custom-format header. This seems unlikely, so let'sfix it by just nuking the duplicate logic in _discoverArchiveFormat().Also get rid of the pointless attempt to seek back to the start ofthe file after successful autodetection. That wastes cycles andit means we have four behaviors to verify not two.Per bug #16951 from Sergey Koposov. This has been broken fordecades, so back-patch to all supported versions.Discussion:https://postgr.es/m/16951-a4dd68cf0de23048@postgresql.org1 parenta126a95 commit84c5e0d
File tree
3 files changed
+51
-110
lines changed- src/bin/pg_dump
3 files changed
+51
-110
lines changedLines changed: 39 additions & 98 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2086 | 2086 |
| |
2087 | 2087 |
| |
2088 | 2088 |
| |
| 2089 | + | |
2089 | 2090 |
| |
2090 | 2091 |
| |
2091 | 2092 |
| |
| |||
2157 | 2158 |
| |
2158 | 2159 |
| |
2159 | 2160 |
| |
2160 |
| - | |
2161 |
| - | |
2162 |
| - | |
2163 |
| - | |
2164 |
| - | |
2165 |
| - | |
2166 |
| - | |
2167 |
| - | |
2168 |
| - | |
2169 |
| - | |
2170 |
| - | |
2171 |
| - | |
2172 |
| - | |
2173 |
| - | |
2174 |
| - | |
2175 |
| - | |
2176 |
| - | |
2177 |
| - | |
2178 |
| - | |
2179 |
| - | |
2180 |
| - | |
2181 |
| - | |
2182 |
| - | |
2183 |
| - | |
2184 |
| - | |
2185 |
| - | |
2186 |
| - | |
2187 |
| - | |
2188 |
| - | |
2189 |
| - | |
2190 |
| - | |
2191 |
| - | |
2192 |
| - | |
2193 |
| - | |
2194 |
| - | |
2195 |
| - | |
2196 |
| - | |
2197 |
| - | |
2198 |
| - | |
2199 |
| - | |
2200 |
| - | |
2201 |
| - | |
2202 |
| - | |
2203 |
| - | |
2204 |
| - | |
2205 |
| - | |
2206 |
| - | |
2207 |
| - | |
2208 |
| - | |
2209 |
| - | |
2210 |
| - | |
2211 |
| - | |
2212 |
| - | |
2213 |
| - | |
2214 |
| - | |
2215 |
| - | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
2216 | 2164 |
| |
2217 | 2165 |
| |
2218 | 2166 |
| |
| |||
2249 | 2197 |
| |
2250 | 2198 |
| |
2251 | 2199 |
| |
2252 |
| - | |
2253 |
| - | |
2254 |
| - | |
2255 |
| - | |
2256 |
| - | |
2257 |
| - | |
2258 |
| - | |
2259 |
| - | |
2260 |
| - | |
2261 |
| - | |
2262 |
| - | |
2263 |
| - | |
2264 |
| - | |
| 2200 | + | |
2265 | 2201 |
| |
| 2202 | + | |
2266 | 2203 |
| |
2267 | 2204 |
| |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
2268 | 2209 |
| |
2269 | 2210 |
| |
2270 | 2211 |
| |
| |||
3773 | 3714 |
| |
3774 | 3715 |
| |
3775 | 3716 |
| |
3776 |
| - | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
3777 | 3720 |
| |
3778 | 3721 |
| |
3779 | 3722 |
| |
| |||
3785 | 3728 |
| |
3786 | 3729 |
| |
3787 | 3730 |
| |
3788 |
| - | |
3789 |
| - | |
3790 |
| - | |
| 3731 | + | |
3791 | 3732 |
| |
3792 | 3733 |
| |
3793 | 3734 |
| |
3794 | 3735 |
| |
3795 | 3736 |
| |
| 3737 | + | |
3796 | 3738 |
| |
3797 |
| - | |
3798 |
| - | |
| 3739 | + | |
| 3740 | + | |
3799 | 3741 |
| |
3800 |
| - | |
3801 |
| - | |
3802 |
| - | |
3803 |
| - | |
| 3742 | + | |
| 3743 | + | |
| 3744 | + | |
| 3745 | + | |
3804 | 3746 |
| |
3805 |
| - | |
| 3747 | + | |
3806 | 3748 |
| |
3807 |
| - | |
3808 |
| - | |
3809 |
| - | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
3810 | 3752 |
| |
3811 |
| - | |
3812 |
| - | |
3813 |
| - | |
3814 |
| - | |
| 3753 | + | |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
3815 | 3757 |
| |
3816 |
| - | |
3817 |
| - | |
| 3758 | + | |
| 3759 | + | |
3818 | 3760 |
| |
3819 |
| - | |
3820 |
| - | |
3821 |
| - | |
3822 |
| - | |
| 3761 | + | |
| 3762 | + | |
| 3763 | + | |
| 3764 | + | |
3823 | 3765 |
| |
3824 |
| - | |
| 3766 | + | |
3825 | 3767 |
| |
3826 |
| - | |
3827 |
| - | |
3828 |
| - | |
3829 |
| - | |
| 3768 | + | |
| 3769 | + | |
| 3770 | + | |
3830 | 3771 |
| |
3831 | 3772 |
| |
3832 | 3773 |
| |
|
Lines changed: 12 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
258 | 258 |
| |
259 | 259 |
| |
260 | 260 |
| |
261 |
| - | |
262 |
| - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
263 | 269 |
| |
264 |
| - | |
| 270 | + | |
265 | 271 |
| |
266 | 272 |
| |
267 |
| - | |
268 |
| - | |
269 |
| - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
270 | 276 |
| |
271 | 277 |
| |
272 | 278 |
| |
|
Lines changed: 0 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
228 | 228 |
| |
229 | 229 |
| |
230 | 230 |
| |
231 |
| - | |
232 |
| - | |
233 |
| - | |
234 |
| - | |
235 |
| - | |
236 |
| - | |
237 | 231 |
| |
238 | 232 |
| |
239 | 233 |
| |
|
0 commit comments
Comments
(0)