forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2eb34ac
committed
Fix problems with "read only query" checks, and refactor the code.
Previously, check_xact_readonly() was responsible for determiningwhich types of queries could not be run in a read-only transaction,standard_ProcessUtility() was responsibility for prohibiting thingswhich were allowed in read only transactions but not in recovery, andutility commands were basically prohibited in bulk in parallel mode bycalls to CommandIsReadOnly() in functions.c and spi.c. This situationwas confusing and error-prone. Accordingly, move all the checks to anew function ClassifyUtilityCommandAsReadOnly(), which determines thedegree to which a given statement is read only.In the old code, check_xact_readonly() inadvertently failed to handleseveral statement types that actually should have been prohibited,specifically T_CreatePolicyStmt, T_AlterPolicyStmt, T_CreateAmStmt,T_CreateStatsStmt, T_AlterStatsStmt, and T_AlterCollationStmt. As aresult, thes statements were erroneously allowed in read onlytransactions, parallel queries, and standby operation. Generally, theywould fail anyway due to some lower-level error check, but weshouldn't rely on that. In the new code structure, future omissionsof this type should cause ClassifyUtilityCommandAsReadOnly() tocomplain about an unrecognized node type.As a fringe benefit, this means we can allow certain types of utilitycommands in parallel mode, where it's safe to do so. This allowsALTER SYSTEM, CALL, DO, CHECKPOINT, COPY FROM, EXPLAIN, and SHOW.It might be possible to allow additional commands with more workand thought.Along the way, document the thinking process behind the current setof checks, as per discussion especially with Peter Eisentraut. Thereis some interest in revising some of these rules, but that seemslike a job for another patch.Patch by me, reviewed by Tom Lane, Stephen Frost, and PeterEisentraut.Discussion:http://postgr.es/m/CA+TgmoZ_rLqJt5sYkvh+JpQnfX0Y+B2R+qfi820xNih6x-FQOQ@mail.gmail.com1 parent0db7c67 commit2eb34ac
File tree
6 files changed
+292
-135
lines changed- src
- backend
- commands
- executor
- tcop
- include/tcop
6 files changed
+292
-135
lines changedLines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1064 | 1064 |
| |
1065 | 1065 |
| |
1066 | 1066 |
| |
1067 |
| - | |
1068 | 1067 |
| |
1069 | 1068 |
| |
1070 | 1069 |
| |
|
Lines changed: 0 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
45 |
| - | |
46 |
| - | |
47 |
| - | |
48 |
| - | |
49 |
| - | |
50 |
| - | |
51 |
| - | |
52 |
| - | |
53 |
| - | |
54 |
| - | |
55 |
| - | |
56 | 45 |
| |
57 | 46 |
| |
58 | 47 |
| |
|
Lines changed: 0 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
540 | 540 |
| |
541 | 541 |
| |
542 | 542 |
| |
543 |
| - | |
544 |
| - | |
545 |
| - | |
546 | 543 |
| |
547 | 544 |
| |
548 | 545 |
| |
|
Lines changed: 11 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1450 | 1450 |
| |
1451 | 1451 |
| |
1452 | 1452 |
| |
1453 |
| - | |
1454 |
| - | |
1455 |
| - | |
1456 |
| - | |
1457 |
| - | |
1458 |
| - | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
1459 | 1458 |
| |
1460 |
| - | |
| 1459 | + | |
1461 | 1460 |
| |
1462 | 1461 |
| |
1463 | 1462 |
| |
| |||
1466 | 1465 |
| |
1467 | 1466 |
| |
1468 | 1467 |
| |
1469 |
| - | |
1470 |
| - | |
1471 |
| - | |
1472 |
| - | |
1473 |
| - | |
1474 |
| - | |
1475 |
| - | |
1476 |
| - | |
1477 |
| - | |
1478 |
| - | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
1479 | 1473 |
| |
1480 | 1474 |
| |
1481 | 1475 |
| |
| |||
2263 | 2257 |
| |
2264 | 2258 |
| |
2265 | 2259 |
| |
2266 |
| - | |
2267 |
| - | |
2268 |
| - | |
2269 | 2260 |
| |
2270 | 2261 |
| |
2271 | 2262 |
| |
|
0 commit comments
Comments
(0)