- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitd9809bf
committed
Fix corner-case uninitialized-variable issues in plpgsql.
If an error was raised during our initial attempt to check whethera successfully-compiled expression is "simple", subsequent calls ofexec_stmt_execsql would suppose that stmt->mod_stmt was already computedwhen it had not been. This could lead to assertion failures in debugbuilds; in production builds the effect would typically be to act asif INTO STRICT had been specified even when it had not been. Of coursethat only matters if the subsequent attempt to execute the expressionsucceeds, so that the problem can only be reached by fixing a failurein some referenced, inline-able SQL function and then retrying thecalling plpgsql function in the same session.(There might be even-more-obscure ways to change the expression'sbehavior without changing the plpgsql function, but that one seemslike the only one people would be likely to hit in practice.)The most foolproof way to fix this would be to arrange forexec_prepare_plan to not set expr->plan until we've finished thesubsidiary simple-expression check. But it seems hard to do thatwithout creating reference-count leak issues. So settle for documentingthe hazard in a comment and fixing exec_stmt_execsql to test separatelyfor whether it's computed stmt->mod_stmt. (That adds a test-and-branchper execution, but hopefully that's negligible in context.) In v11 andup, also fix exec_stmt_call which had a variant of the same issue.Per bug #17113 from Alexander Lakhin. Back-patch to allsupported branches.Discussion:https://postgr.es/m/17113-077605ce00e0e7ec@postgresql.org1 parent91d395f commitd9809bf
File tree
5 files changed
+84
-18
lines changed- src/pl/plpgsql/src
- expected
- sql
5 files changed
+84
-18
lines changedLines changed: 23 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
66 | 66 |
| |
67 | 67 |
| |
68 | 68 |
| |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + |
Lines changed: 37 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2162 | 2162 |
| |
2163 | 2163 |
| |
2164 | 2164 |
| |
2165 |
| - | |
2166 | 2165 |
| |
2167 | 2166 |
| |
2168 |
| - | |
2169 |
| - | |
2170 |
| - | |
2171 |
| - | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
2172 | 2171 |
| |
2173 |
| - | |
2174 |
| - | |
2175 |
| - | |
2176 |
| - | |
2177 |
| - | |
2178 |
| - | |
2179 |
| - | |
2180 |
| - | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
2181 | 2179 |
| |
2182 | 2180 |
| |
2183 | 2181 |
| |
| |||
4093 | 4091 |
| |
4094 | 4092 |
| |
4095 | 4093 |
| |
| 4094 | + | |
| 4095 | + | |
| 4096 | + | |
| 4097 | + | |
| 4098 | + | |
| 4099 | + | |
| 4100 | + | |
| 4101 | + | |
| 4102 | + | |
| 4103 | + | |
| 4104 | + | |
| 4105 | + | |
| 4106 | + | |
| 4107 | + | |
| 4108 | + | |
| 4109 | + | |
4096 | 4110 |
| |
4097 | 4111 |
| |
4098 | 4112 |
| |
| |||
4156 | 4170 |
| |
4157 | 4171 |
| |
4158 | 4172 |
| |
| 4173 | + | |
| 4174 | + | |
| 4175 | + | |
4159 | 4176 |
| |
4160 | 4177 |
| |
4161 | 4178 |
| |
4162 |
| - | |
4163 | 4179 |
| |
4164 | 4180 |
| |
4165 | 4181 |
| |
| |||
4179 | 4195 |
| |
4180 | 4196 |
| |
4181 | 4197 |
| |
| 4198 | + | |
4182 | 4199 |
| |
4183 | 4200 |
| |
4184 | 4201 |
| |
| |||
7846 | 7863 |
| |
7847 | 7864 |
| |
7848 | 7865 |
| |
| 7866 | + | |
| 7867 | + | |
| 7868 | + | |
| 7869 | + | |
7849 | 7870 |
| |
7850 | 7871 |
| |
7851 | 7872 |
| |
| |||
7929 | 7950 |
| |
7930 | 7951 |
| |
7931 | 7952 |
| |
7932 |
| - | |
| 7953 | + | |
| 7954 | + | |
7933 | 7955 |
| |
7934 | 7956 |
| |
7935 | 7957 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3043 | 3043 |
| |
3044 | 3044 |
| |
3045 | 3045 |
| |
3046 |
| - | |
| 3046 | + | |
3047 | 3047 |
| |
3048 | 3048 |
| |
3049 | 3049 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
893 | 893 |
| |
894 | 894 |
| |
895 | 895 |
| |
896 |
| - | |
897 |
| - | |
| 896 | + | |
| 897 | + | |
898 | 898 |
| |
899 | 899 |
| |
900 | 900 |
| |
|
Lines changed: 21 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
59 | 59 |
| |
60 | 60 |
| |
61 | 61 |
| |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + |
0 commit comments
Comments
(0)