- Notifications
You must be signed in to change notification settings - Fork5
Commit0900ac2
committed
Fix plpgsql's reporting of plan-time errors in possibly-simple expressions.
exec_simple_check_plan and exec_eval_simple_expr attempted to callGetCachedPlan directly. This meant that if an error was thrown duringplanning, the resulting context traceback would not include the linenormally contributed by _SPI_error_callback. This is already inconsistent,but just to be really odd, a re-execution of the very same expression*would* show the additional context line, because we'd already have cachedthe plan and marked the expression as non-simple.The problem is easy to demonstrate in 9.2 and HEAD because planning of acached plan doesn't occur at all until GetCachedPlan is done. In earlierversions, it could only be an issue if initial planning had succeeded, thena replan was forced (already somewhat improbable for a simple expression),and the replan attempt failed. Since the issue is mainly cosmetic in olderbranches anyway, it doesn't seem worth the risk of trying to fix it there.It is worth fixing in 9.2 since the instability of the context printout canaffect the results of GET STACKED DIAGNOSTICS, as per a recent discussionon pgsql-novice.To fix, introduce a SPI function that wraps GetCachedPlan while installingthe correct callback function. Use this instead of calling GetCachedPlandirectly from plpgsql.Also introduce a wrapper function for extracting a SPI plan'sCachedPlanSource list. This lets us stop including spi_priv.h inpl_exec.c, which was never a very good idea from a modularity standpoint.In passing, fix a similar inconsistency that could occur in SPI_cursor_open,which was also calling GetCachedPlan without setting up a context callback.1 parent670a6c7 commit0900ac2
File tree
5 files changed
+126
-19
lines changed- src
- backend/executor
- include/executor
- pl/plpgsql/src
- test/regress
- expected
- sql
5 files changed
+126
-19
lines changedLines changed: 72 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1132 | 1132 |
| |
1133 | 1133 |
| |
1134 | 1134 |
| |
| 1135 | + | |
1135 | 1136 |
| |
1136 | 1137 |
| |
1137 | 1138 |
| |
| |||
1181 | 1182 |
| |
1182 | 1183 |
| |
1183 | 1184 |
| |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
1184 | 1194 |
| |
1185 | 1195 |
| |
1186 | 1196 |
| |
| |||
1191 | 1201 |
| |
1192 | 1202 |
| |
1193 | 1203 |
| |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
1194 | 1207 |
| |
1195 | 1208 |
| |
1196 | 1209 |
| |
| |||
1552 | 1565 |
| |
1553 | 1566 |
| |
1554 | 1567 |
| |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
1555 | 1627 |
| |
1556 | 1628 |
| |
1557 | 1629 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
103 | 103 |
| |
104 | 104 |
| |
105 | 105 |
| |
| 106 | + | |
| 107 | + | |
| 108 | + | |
106 | 109 |
| |
107 | 110 |
| |
108 | 111 |
| |
|
Lines changed: 23 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
22 | 22 |
| |
23 | 23 |
| |
24 | 24 |
| |
25 |
| - | |
| 25 | + | |
26 | 26 |
| |
27 | 27 |
| |
28 | 28 |
| |
| |||
3174 | 3174 |
| |
3175 | 3175 |
| |
3176 | 3176 |
| |
3177 |
| - | |
| 3177 | + | |
3178 | 3178 |
| |
3179 | 3179 |
| |
3180 | 3180 |
| |
| |||
4954 | 4954 |
| |
4955 | 4955 |
| |
4956 | 4956 |
| |
4957 |
| - | |
4958 |
| - | |
4959 |
| - | |
4960 |
| - | |
| 4957 | + | |
| 4958 | + | |
| 4959 | + | |
| 4960 | + | |
| 4961 | + | |
4961 | 4962 |
| |
4962 | 4963 |
| |
4963 | 4964 |
| |
| |||
4973 | 4974 |
| |
4974 | 4975 |
| |
4975 | 4976 |
| |
4976 |
| - | |
4977 | 4977 |
| |
4978 | 4978 |
| |
4979 | 4979 |
| |
| |||
4993 | 4993 |
| |
4994 | 4994 |
| |
4995 | 4995 |
| |
4996 |
| - | |
4997 |
| - | |
4998 |
| - | |
| 4996 | + | |
4999 | 4997 |
| |
5000 |
| - | |
5001 |
| - | |
| 4998 | + | |
5002 | 4999 |
| |
5003 |
| - | |
5004 |
| - | |
5005 |
| - | |
| 5000 | + | |
| 5001 | + | |
| 5002 | + | |
| 5003 | + | |
| 5004 | + | |
| 5005 | + | |
5006 | 5006 |
| |
5007 | 5007 |
| |
5008 | 5008 |
| |
| |||
5893 | 5893 |
| |
5894 | 5894 |
| |
5895 | 5895 |
| |
| 5896 | + | |
5896 | 5897 |
| |
5897 | 5898 |
| |
5898 | 5899 |
| |
| |||
5908 | 5909 |
| |
5909 | 5910 |
| |
5910 | 5911 |
| |
5911 |
| - | |
| 5912 | + | |
| 5913 | + | |
5912 | 5914 |
| |
5913 |
| - | |
| 5915 | + | |
5914 | 5916 |
| |
5915 | 5917 |
| |
5916 | 5918 |
| |
| |||
5968 | 5970 |
| |
5969 | 5971 |
| |
5970 | 5972 |
| |
5971 |
| - | |
5972 |
| - | |
| 5973 | + | |
| 5974 | + | |
| 5975 | + | |
| 5976 | + | |
5973 | 5977 |
| |
5974 | 5978 |
| |
5975 | 5979 |
| |
|
Lines changed: 15 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4387 | 4387 |
| |
4388 | 4388 |
| |
4389 | 4389 |
| |
| 4390 | + | |
| 4391 | + | |
| 4392 | + | |
| 4393 | + | |
| 4394 | + | |
| 4395 | + | |
| 4396 | + | |
| 4397 | + | |
| 4398 | + | |
| 4399 | + | |
| 4400 | + | |
| 4401 | + | |
| 4402 | + | |
| 4403 | + | |
| 4404 | + | |
4390 | 4405 |
| |
4391 | 4406 |
| |
4392 | 4407 |
| |
|
Lines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3537 | 3537 |
| |
3538 | 3538 |
| |
3539 | 3539 |
| |
| 3540 | + | |
| 3541 | + | |
| 3542 | + | |
| 3543 | + | |
| 3544 | + | |
| 3545 | + | |
| 3546 | + | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
3540 | 3553 |
| |
3541 | 3554 |
| |
3542 | 3555 |
| |
|
0 commit comments
Comments
(0)