forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit290c2da
committed
Handle unexpected query results, especially NULLs, safely in connectby().
connectby() didn't adequately check that the constructed SQL query returnswhat it's expected to; in fact, since commit08c33c4 it wasn'tchecking that at all. This could result in a null-pointer-dereferencecrash if the constructed query returns only one column instead of theexpected two. Less excitingly, it could also result in surprising dataconversion failures if the constructed query returned values that werenot I/O-conversion-compatible with the types specified by the querycalling connectby().In all branches, insist that the query return at least two columns;this seems like a minimal sanity check that can't break any reasonableuse-cases.In HEAD, insist that the constructed query return the types specified bythe outer query, including checking for typmod incompatibility, which thecode never did even before it got broken. This is to hide the fact thatthe implementation does a conversion to text and back; someday we mightwant to improve that.In back branches, leave that alone, since adding a type check in a minorrelease is more likely to break things than make people happy. Typeinconsistencies will continue to work so long as the actual type anddeclared type are I/O representation compatible, and otherwise will failthe same way they used to.Also, in all branches, be on guard for NULL results from the constructedquery, which formerly would cause null-pointer dereference crashes.We now print the row with the NULL but don't recurse down from it.In passing, get rid of the rather pointless idea thatbuild_tuplestore_recursively() should return the same tuplestore that'spassed to it.Michael Paquier, adjusted somewhat by me1 parent78f8c67 commit290c2da
File tree
3 files changed
+116
-83
lines changed- contrib/tablefunc
- expected
- sql
3 files changed
+116
-83
lines changedLines changed: 31 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
377 | 377 |
| |
378 | 378 |
| |
379 | 379 |
| |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
380 | 411 |
| |
381 | 412 |
| |
382 | 413 |
| |
|
Lines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
179 | 179 |
| |
180 | 180 |
| |
181 | 181 |
| |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
182 | 198 |
| |
183 | 199 |
| |
184 | 200 |
| |
|
Lines changed: 69 additions & 83 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
56 | 56 |
| |
57 | 57 |
| |
58 | 58 |
| |
59 |
| - | |
| 59 | + | |
60 | 60 |
| |
61 | 61 |
| |
62 | 62 |
| |
| |||
70 | 70 |
| |
71 | 71 |
| |
72 | 72 |
| |
73 |
| - | |
| 73 | + | |
74 | 74 |
| |
75 | 75 |
| |
76 | 76 |
| |
| |||
1180 | 1180 |
| |
1181 | 1181 |
| |
1182 | 1182 |
| |
1183 |
| - | |
1184 |
| - | |
1185 |
| - | |
1186 |
| - | |
1187 |
| - | |
1188 |
| - | |
1189 |
| - | |
1190 |
| - | |
1191 |
| - | |
1192 |
| - | |
1193 |
| - | |
1194 |
| - | |
1195 |
| - | |
1196 |
| - | |
1197 |
| - | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
1198 | 1198 |
| |
1199 | 1199 |
| |
1200 | 1200 |
| |
1201 | 1201 |
| |
1202 | 1202 |
| |
1203 | 1203 |
| |
1204 |
| - | |
| 1204 | + | |
1205 | 1205 |
| |
1206 | 1206 |
| |
1207 | 1207 |
| |
| |||
1232 | 1232 |
| |
1233 | 1233 |
| |
1234 | 1234 |
| |
1235 |
| - | |
| 1235 | + | |
1236 | 1236 |
| |
1237 | 1237 |
| |
1238 | 1238 |
| |
| |||
1318 | 1318 |
| |
1319 | 1319 |
| |
1320 | 1320 |
| |
1321 |
| - | |
1322 |
| - | |
1323 |
| - | |
1324 |
| - | |
1325 |
| - | |
1326 |
| - | |
1327 |
| - | |
1328 |
| - | |
1329 |
| - | |
1330 |
| - | |
1331 |
| - | |
1332 |
| - | |
1333 |
| - | |
1334 |
| - | |
1335 |
| - | |
1336 |
| - | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
1337 | 1326 |
| |
1338 | 1327 |
| |
1339 | 1328 |
| |
| |||
1348 | 1337 |
| |
1349 | 1338 |
| |
1350 | 1339 |
| |
1351 |
| - | |
| 1340 | + | |
1352 | 1341 |
| |
1353 |
| - | |
1354 |
| - | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
1355 | 1345 |
| |
1356 | 1346 |
| |
1357 | 1347 |
| |
1358 | 1348 |
| |
1359 | 1349 |
| |
1360 |
| - | |
1361 |
| - | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
1362 | 1357 |
| |
1363 | 1358 |
| |
1364 |
| - | |
| 1359 | + | |
| 1360 | + | |
1365 | 1361 |
| |
1366 | 1362 |
| |
1367 | 1363 |
| |
1368 |
| - | |
| 1364 | + | |
1369 | 1365 |
| |
1370 | 1366 |
| |
1371 | 1367 |
| |
| |||
1381 | 1377 |
| |
1382 | 1378 |
| |
1383 | 1379 |
| |
1384 |
| - | |
1385 |
| - | |
1386 |
| - | |
1387 | 1380 |
| |
1388 | 1381 |
| |
1389 | 1382 |
| |
1390 | 1383 |
| |
1391 | 1384 |
| |
1392 |
| - | |
1393 |
| - | |
1394 |
| - | |
1395 |
| - | |
1396 |
| - | |
1397 |
| - | |
1398 |
| - | |
1399 |
| - | |
1400 |
| - | |
1401 |
| - | |
1402 |
| - | |
1403 |
| - | |
1404 |
| - | |
1405 |
| - | |
1406 |
| - | |
1407 |
| - | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
1408 | 1405 |
| |
1409 | 1406 |
| |
1410 | 1407 |
| |
| |||
1416 | 1413 |
| |
1417 | 1414 |
| |
1418 | 1415 |
| |
1419 |
| - | |
1420 |
| - | |
1421 | 1416 |
| |
1422 | 1417 |
| |
1423 | 1418 |
| |
| |||
1490 | 1485 |
| |
1491 | 1486 |
| |
1492 | 1487 |
| |
1493 |
| - | |
| 1488 | + | |
1494 | 1489 |
| |
1495 | 1490 |
| |
1496 |
| - | |
1497 |
| - | |
1498 |
| - | |
1499 |
| - | |
1500 |
| - | |
1501 |
| - | |
1502 |
| - | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
1503 | 1495 |
| |
1504 | 1496 |
| |
1505 | 1497 |
| |
1506 |
| - | |
1507 |
| - | |
| 1498 | + | |
1508 | 1499 |
| |
1509 |
| - | |
1510 |
| - | |
1511 |
| - | |
1512 |
| - | |
1513 |
| - | |
1514 |
| - | |
1515 |
| - | |
1516 |
| - | |
1517 |
| - | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
1518 | 1505 |
| |
1519 | 1506 |
| |
1520 |
| - | |
1521 | 1507 |
| |
1522 | 1508 |
| |
1523 | 1509 |
| |
|
0 commit comments
Comments
(0)