forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5afcd2a
committed
Fix multiple portability issues in pg_upgrade's rewriteVisibilityMap().
This is new code in 9.6, and evidently we missed out testing it asthoroughly as it should have been. Bugs fixed here:1. Use binary not text mode to open the files on Windows. Before, ifthe visibility map chanced to contain two bytes that looked like \r\n,Windows' read() would convert that to \n, which both corrupts the mapdata and causes the file to look shorter than it should. Unless youwere *very* unlucky and had an exact multiple of 8K such occurrencesin each VM file, this would cause pg_upgrade to report a failure,though with a rather obscure error message.2. The code for copying rebuilt bytes into the output was simply wrong.It chanced to work okay on little-endian machines but would emit thebytes in the wrong order on big-endian, leading to silent corruptionof the visibility map data.3. The code was careless about alignment of the working buffers. Givenall three of an alignment-picky architecture, a compiler that choosesto put the new_vmbuf[] local variable at an odd starting address, anda checksum-enabled database, pg_upgrade would dump core.Point one was reported by Thomas Kellerer, the other two detected bycode-reading.Point two is much the nastiest of these issues from an impact standpoint,though fortunately it affects only a minority of users. The Windows issuewill definitely bite people, but it seems quite unlikely that there wouldbe undetected corruption from that.In addition, I failed to resist the temptation to do some minor cosmeticadjustments, mostly improving the comments.It would be a good idea to try to improve the error reporting here, butthat seems like material for a separate patch.Discussion: <nsjrbh$8li$1@blaine.gmane.org>1 parentcd03890 commit5afcd2a
1 file changed
+49
-42
lines changedLines changed: 49 additions & 42 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
21 |
| - | |
22 |
| - | |
23 | 21 |
| |
24 | 22 |
| |
25 | 23 |
| |
| |||
84 | 82 |
| |
85 | 83 |
| |
86 | 84 |
| |
87 |
| - | |
| 85 | + | |
88 | 86 |
| |
89 | 87 |
| |
90 |
| - | |
| 88 | + | |
| 89 | + | |
91 | 90 |
| |
92 | 91 |
| |
93 | 92 |
| |
| |||
153 | 152 |
| |
154 | 153 |
| |
155 | 154 |
| |
156 |
| - | |
157 |
| - | |
158 |
| - | |
159 |
| - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
160 | 158 |
| |
161 | 159 |
| |
162 | 160 |
| |
163 | 161 |
| |
164 |
| - | |
165 |
| - | |
166 |
| - | |
167 |
| - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
168 | 166 |
| |
169 | 167 |
| |
170 | 168 |
| |
171 | 169 |
| |
172 | 170 |
| |
173 | 171 |
| |
174 |
| - | |
| 172 | + | |
175 | 173 |
| |
176 | 174 |
| |
177 | 175 |
| |
178 | 176 |
| |
179 | 177 |
| |
180 |
| - | |
| 178 | + | |
181 | 179 |
| |
182 | 180 |
| |
183 | 181 |
| |
| |||
186 | 184 |
| |
187 | 185 |
| |
188 | 186 |
| |
189 |
| - | |
| 187 | + | |
| 188 | + | |
190 | 189 |
| |
191 | 190 |
| |
192 | 191 |
| |
| |||
195 | 194 |
| |
196 | 195 |
| |
197 | 196 |
| |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
198 | 204 |
| |
199 | 205 |
| |
200 |
| - | |
201 |
| - | |
202 |
| - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
203 | 209 |
| |
204 | 210 |
| |
205 | 211 |
| |
| 212 | + | |
206 | 213 |
| |
207 | 214 |
| |
208 | 215 |
| |
| |||
225 | 232 |
| |
226 | 233 |
| |
227 | 234 |
| |
228 |
| - | |
229 |
| - | |
230 |
| - | |
| 235 | + | |
| 236 | + | |
231 | 237 |
| |
232 | 238 |
| |
233 | 239 |
| |
234 | 240 |
| |
235 | 241 |
| |
236 |
| - | |
| 242 | + | |
237 | 243 |
| |
238 |
| - | |
239 |
| - | |
| 244 | + | |
240 | 245 |
| |
241 | 246 |
| |
242 | 247 |
| |
243 |
| - | |
| 248 | + | |
244 | 249 |
| |
245 | 250 |
| |
246 |
| - | |
247 |
| - | |
| 251 | + | |
| 252 | + | |
248 | 253 |
| |
249 |
| - | |
| 254 | + | |
250 | 255 |
| |
251 | 256 |
| |
252 |
| - | |
| 257 | + | |
253 | 258 |
| |
| 259 | + | |
254 | 260 |
| |
255 | 261 |
| |
256 | 262 |
| |
257 | 263 |
| |
258 | 264 |
| |
259 | 265 |
| |
260 |
| - | |
261 |
| - | |
262 |
| - | |
| 266 | + | |
263 | 267 |
| |
264 | 268 |
| |
265 |
| - | |
| 269 | + | |
| 270 | + | |
266 | 271 |
| |
267 | 272 |
| |
268 | 273 |
| |
269 |
| - | |
270 |
| - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
271 | 277 |
| |
272 |
| - | |
| 278 | + | |
273 | 279 |
| |
274 | 280 |
| |
275 | 281 |
| |
276 |
| - | |
| 282 | + | |
277 | 283 |
| |
278 | 284 |
| |
279 | 285 |
| |
280 |
| - | |
281 |
| - | |
282 |
| - | |
| 286 | + | |
| 287 | + | |
283 | 288 |
| |
284 | 289 |
| |
285 | 290 |
| |
| |||
290 | 295 |
| |
291 | 296 |
| |
292 | 297 |
| |
| 298 | + | |
293 | 299 |
| |
294 | 300 |
| |
295 | 301 |
| |
296 | 302 |
| |
297 | 303 |
| |
298 |
| - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
299 | 307 |
| |
300 | 308 |
| |
301 | 309 |
| |
302 | 310 |
| |
303 |
| - | |
304 | 311 |
| |
305 | 312 |
| |
306 | 313 |
| |
|
0 commit comments
Comments
(0)