forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2e70d6b
committed
Teach libpq to detect integer overflow in the row count of a PGresult.
Adding more than 1 billion rows to a PGresult would overflow its ntups andtupArrSize fields, leading to client crashes. It'd be desirable to usewider fields on 64-bit machines, but because all of libpq's external APIsuse plain "int" for row counters, that's going to be hard to accomplishwithout an ABI break. Given the lack of complaints so far, and the generalpain that would be involved in using such huge PGresults, let's settle forjust preventing the overflow and reporting a useful error message if itdoes happen. Also, for a couple more lines of code we can increase thethreshold of trouble from INT_MAX/2 to INT_MAX rows.To do that, refactor pqAddTuple() to allow returning an error message thatreplaces the default assumption that it failed because of out-of-memory.Along the way, fix PQsetvalue() so that it reports all failures viapqInternalNotice(). It already did so in the case of bad field number,but neglected to report anything for other error causes.Because of the potential for crashes, this seems like a back-patchablebug fix, despite the lack of field reports.Michael Paquier, per a complaint from Igor Korot.Discussion:https://postgr.es/m/CA+FnnTxyLWyjY1goewmJNxC==HQCCF4fKkoCTa9qR36oRAHDPw@mail.gmail.com1 parentbf11e7e commit2e70d6b
1 file changed
+60
-9
lines changedLines changed: 60 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
16 | 16 |
| |
17 | 17 |
| |
18 | 18 |
| |
| 19 | + | |
19 | 20 |
| |
20 | 21 |
| |
21 | 22 |
| |
| |||
51 | 52 |
| |
52 | 53 |
| |
53 | 54 |
| |
54 |
| - | |
| 55 | + | |
| 56 | + | |
55 | 57 |
| |
56 | 58 |
| |
57 | 59 |
| |
| |||
416 | 418 |
| |
417 | 419 |
| |
418 | 420 |
| |
| 421 | + | |
419 | 422 |
| |
420 | 423 |
| |
421 | 424 |
| |
422 | 425 |
| |
423 | 426 |
| |
| 427 | + | |
424 | 428 |
| |
| 429 | + | |
425 | 430 |
| |
426 | 431 |
| |
427 | 432 |
| |
428 | 433 |
| |
429 | 434 |
| |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
430 | 439 |
| |
| 440 | + | |
431 | 441 |
| |
432 | 442 |
| |
433 | 443 |
| |
| |||
440 | 450 |
| |
441 | 451 |
| |
442 | 452 |
| |
443 |
| - | |
| 453 | + | |
444 | 454 |
| |
445 | 455 |
| |
446 | 456 |
| |
| |||
450 | 460 |
| |
451 | 461 |
| |
452 | 462 |
| |
453 |
| - | |
454 |
| - | |
| 463 | + | |
| 464 | + | |
455 | 465 |
| |
456 | 466 |
| |
457 | 467 |
| |
| |||
471 | 481 |
| |
472 | 482 |
| |
473 | 483 |
| |
474 |
| - | |
| 484 | + | |
475 | 485 |
| |
476 | 486 |
| |
477 | 487 |
| |
478 | 488 |
| |
479 | 489 |
| |
480 | 490 |
| |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
481 | 502 |
| |
482 | 503 |
| |
483 | 504 |
| |
| |||
847 | 868 |
| |
848 | 869 |
| |
849 | 870 |
| |
850 |
| - | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
851 | 875 |
| |
852 | 876 |
| |
853 |
| - | |
| 877 | + | |
854 | 878 |
| |
855 | 879 |
| |
856 | 880 |
| |
| |||
865 | 889 |
| |
866 | 890 |
| |
867 | 891 |
| |
868 |
| - | |
| 892 | + | |
869 | 893 |
| |
870 | 894 |
| |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
871 | 922 |
| |
872 | 923 |
| |
873 | 924 |
| |
| |||
1093 | 1144 |
| |
1094 | 1145 |
| |
1095 | 1146 |
| |
1096 |
| - | |
| 1147 | + | |
1097 | 1148 |
| |
1098 | 1149 |
| |
1099 | 1150 |
| |
|
0 commit comments
Comments
(0)