- Notifications
You must be signed in to change notification settings - Fork5
Commit051d1ba
committed
Avoid recursion while processing ELSIF lists in plpgsql.
The original implementation of ELSIF in plpgsql converted the constructinto nested simple IF statements. This was prone to stack overflow withlong ELSIF lists, in two different ways. First, it's difficult to generatethe parsetree without using right-recursion in the bison grammar, andthat's prone to parser stack overflow since nothing can be reduced untilthe whole list has been read. Second, we'd recurse during execution, thuscreating an unnecessary risk of execution-time stack overflow. Rewriteso that the ELSIF list is represented as a flat list, scanned via iterationnot recursion, and generated through left-recursion in the grammar.Per a gripe from Håvard Kongsgård.1 parent756a4ed commit051d1ba
4 files changed
+66
-50
lines changedLines changed: 19 additions & 31 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
186 | 186 |
| |
187 | 187 |
| |
188 | 188 |
| |
189 |
| - | |
| 189 | + | |
190 | 190 |
| |
191 | 191 |
| |
192 | 192 |
| |
| |||
1007 | 1007 |
| |
1008 | 1008 |
| |
1009 | 1009 |
| |
1010 |
| - | |
| 1010 | + | |
1011 | 1011 |
| |
1012 | 1012 |
| |
1013 | 1013 |
| |
1014 | 1014 |
| |
1015 | 1015 |
| |
1016 | 1016 |
| |
1017 | 1017 |
| |
1018 |
| - | |
1019 |
| - | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
1020 | 1021 |
| |
1021 | 1022 |
| |
1022 | 1023 |
| |
1023 | 1024 |
| |
1024 | 1025 |
| |
1025 |
| - | |
| 1026 | + | |
1026 | 1027 |
| |
1027 | 1028 |
| |
1028 | 1029 |
| |
1029 |
| - | |
1030 |
| - | |
1031 |
| - | |
1032 |
| - | |
1033 |
| - | |
1034 |
| - | |
1035 |
| - | |
1036 |
| - | |
1037 |
| - | |
1038 |
| - | |
1039 |
| - | |
1040 |
| - | |
1041 |
| - | |
1042 |
| - | |
1043 |
| - | |
1044 |
| - | |
1045 |
| - | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
1046 | 1033 |
| |
1047 |
| - | |
1048 |
| - | |
1049 |
| - | |
1050 |
| - | |
1051 |
| - | |
1052 |
| - | |
1053 |
| - | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
1054 | 1038 |
| |
1055 |
| - | |
1056 |
| - | |
| 1039 | + | |
1057 | 1040 |
| |
| 1041 | + | |
1058 | 1042 |
| |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
1059 | 1047 |
| |
1060 | 1048 |
| |
1061 | 1049 |
| |
|
Lines changed: 11 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1510 | 1510 |
| |
1511 | 1511 |
| |
1512 | 1512 |
| |
| 1513 | + | |
1513 | 1514 |
| |
1514 | 1515 |
| |
1515 | 1516 |
| |
1516 |
| - | |
1517 | 1517 |
| |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
1518 | 1521 |
| |
1519 |
| - | |
1520 |
| - | |
1521 |
| - | |
1522 |
| - | |
1523 |
| - | |
1524 |
| - | |
1525 |
| - | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
1526 | 1528 |
| |
1527 | 1529 |
| |
1528 |
| - | |
| 1530 | + | |
1529 | 1531 |
| |
1530 | 1532 |
| |
1531 | 1533 |
| |
|
Lines changed: 25 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
446 | 446 |
| |
447 | 447 |
| |
448 | 448 |
| |
| 449 | + | |
| 450 | + | |
449 | 451 |
| |
450 |
| - | |
451 |
| - | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
452 | 461 |
| |
453 | 462 |
| |
454 | 463 |
| |
| |||
877 | 886 |
| |
878 | 887 |
| |
879 | 888 |
| |
| 889 | + | |
| 890 | + | |
880 | 891 |
| |
881 | 892 |
| |
882 | 893 |
| |
883 | 894 |
| |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
884 | 899 |
| |
885 |
| - | |
886 |
| - | |
887 |
| - | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
888 | 907 |
| |
889 | 908 |
| |
890 | 909 |
| |
891 |
| - | |
| 910 | + | |
892 | 911 |
| |
893 |
| - | |
894 | 912 |
| |
895 | 913 |
| |
896 | 914 |
| |
|
Lines changed: 11 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
396 | 396 |
| |
397 | 397 |
| |
398 | 398 |
| |
399 |
| - | |
400 |
| - | |
401 |
| - | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
402 | 403 |
| |
403 | 404 |
| |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
404 | 412 |
| |
405 | 413 |
| |
406 | 414 |
| |
|
0 commit comments
Comments
(0)