forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6aa5186
committed
Fix limitations on what SQL commands can be issued to a walsender.
In logical replication mode, a WalSender is supposed to be ableto execute any regular SQL command, as well as the specialreplication commands. Poor design of the replication-commandparser caused it to fail in various cases, notably:* semicolons embedded in a command, or multiple SQL commandssent in a single message;* dollar-quoted literals containing odd numbers of singleor double quote marks;* commands starting with a comment.The basic problem here is that we're trying to run repl_scanner.lacross the entire input string even when it's not a replicationcommand. Since repl_scanner.l does not understand all of thetoken types known to the core lexer, this is doomed to havefailure modes.We certainly don't want to make repl_scanner.l as big as scan.l,so instead rejigger stuff so that we only lex the first token ofa non-replication command. That will usually look like an IDENTto repl_scanner.l, though a comment would end up getting reportedas a '-' or '/' single-character token. If the token is a replicationcommand keyword, we push it back and proceed normally with repl_gram.yparsing. Otherwise, we can drop out of exec_replication_command()without examining the rest of the string.(It's still theoretically possible for repl_scanner.l to fail onthe first token; but that could only happen if it's an unterminatedsingle- or double-quoted string, in which case you'd have gottenlargely the same error from the core lexer too.)In this way, repl_gram.y isn't involved at all in handling generalSQL commands, so we can get rid of the SQLCmd node type. (Inthe back branches, we can't remove it because renumbering enumNodeTag would be an ABI break; so just leave it sit there unused.)I failed to resist the temptation to clean up some other sloppycoding in repl_scanner.l while at it. The only externally-visiblebehavior change from that is it now accepts \r and \f as whitespace,same as the core lexer.Per bug #17379 from Greg Rychlewski. Back-patch to all supportedbranches.Discussion:https://postgr.es/m/17379-6a5c6cfb3f1f5e77@postgresql.org1 parent0ad8032 commit6aa5186
File tree
6 files changed
+98
-69
lines changed- src
- backend/replication
- include
- nodes
- replication
6 files changed
+98
-69
lines changedLines changed: 1 addition & 25 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
25 | 25 |
| |
26 | 26 |
| |
27 | 27 |
| |
28 |
| - | |
29 |
| - | |
30 | 28 |
| |
31 | 29 |
| |
32 | 30 |
| |
| |||
59 | 57 |
| |
60 | 58 |
| |
61 | 59 |
| |
62 |
| - | |
63 | 60 |
| |
64 | 61 |
| |
65 | 62 |
| |
| |||
95 | 92 |
| |
96 | 93 |
| |
97 | 94 |
| |
98 |
| - | |
| 95 | + | |
99 | 96 |
| |
100 | 97 |
| |
101 | 98 |
| |
| |||
129 | 126 |
| |
130 | 127 |
| |
131 | 128 |
| |
132 |
| - | |
133 | 129 |
| |
134 | 130 |
| |
135 | 131 |
| |
| |||
450 | 446 |
| |
451 | 447 |
| |
452 | 448 |
| |
453 |
| - | |
454 |
| - | |
455 |
| - | |
456 |
| - | |
457 | 449 |
| |
458 | 450 |
| |
459 | 451 |
| |
| |||
514 | 506 |
| |
515 | 507 |
| |
516 | 508 |
| |
517 |
| - | |
518 |
| - | |
519 |
| - | |
520 |
| - | |
521 |
| - | |
522 |
| - | |
523 |
| - | |
524 |
| - | |
525 |
| - | |
526 |
| - | |
527 |
| - | |
528 |
| - | |
529 |
| - | |
530 |
| - | |
531 |
| - | |
532 |
| - | |
533 | 509 |
|
Lines changed: 70 additions & 17 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
31 | 31 |
| |
32 | 32 |
| |
33 | 33 |
| |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
34 | 38 |
| |
35 | 39 |
| |
36 | 40 |
| |
| |||
51 | 55 |
| |
52 | 56 |
| |
53 | 57 |
| |
54 |
| - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
55 | 70 |
| |
56 | 71 |
| |
57 | 72 |
| |
| |||
69 | 84 |
| |
70 | 85 |
| |
71 | 86 |
| |
72 |
| - | |
73 |
| - | |
74 |
| - | |
75 |
| - | |
76 |
| - | |
| 87 | + | |
| 88 | + | |
77 | 89 |
| |
78 | 90 |
| |
79 | 91 |
| |
| |||
82 | 94 |
| |
83 | 95 |
| |
84 | 96 |
| |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
85 | 110 |
| |
86 | 111 |
| |
87 | 112 |
| |
| |||
112 | 137 |
| |
113 | 138 |
| |
114 | 139 |
| |
115 |
| - | |
116 |
| - | |
117 |
| - | |
118 |
| - | |
119 |
| - | |
120 |
| - | |
121 |
| - | |
122 |
| - | |
| 140 | + | |
123 | 141 |
| |
124 | 142 |
| |
125 | 143 |
| |
| |||
181 | 199 |
| |
182 | 200 |
| |
183 | 201 |
| |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
184 | 207 |
| |
185 | 208 |
| |
186 | 209 |
| |
187 | 210 |
| |
188 | 211 |
| |
189 | 212 |
| |
190 | 213 |
| |
191 |
| - | |
192 |
| - | |
193 |
| - | |
194 | 214 |
| |
195 | 215 |
| |
196 | 216 |
| |
| |||
250 | 270 |
| |
251 | 271 |
| |
252 | 272 |
| |
| 273 | + | |
253 | 274 |
| |
254 | 275 |
| |
255 | 276 |
| |
| |||
258 | 279 |
| |
259 | 280 |
| |
260 | 281 |
| |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + |
Lines changed: 26 additions & 17 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1630 | 1630 |
| |
1631 | 1631 |
| |
1632 | 1632 |
| |
1633 |
| - | |
| 1633 | + | |
| 1634 | + | |
1634 | 1635 |
| |
1635 | 1636 |
| |
1636 | 1637 |
| |
| |||
1641 | 1642 |
| |
1642 | 1643 |
| |
1643 | 1644 |
| |
1644 |
| - | |
| 1645 | + | |
1645 | 1646 |
| |
1646 | 1647 |
| |
1647 | 1648 |
| |
1648 | 1649 |
| |
1649 | 1650 |
| |
1650 | 1651 |
| |
1651 | 1652 |
| |
1652 |
| - | |
1653 |
| - | |
1654 |
| - | |
1655 |
| - | |
1656 |
| - | |
1657 |
| - | |
1658 |
| - | |
1659 |
| - | |
1660 |
| - | |
1661 | 1653 |
| |
1662 | 1654 |
| |
1663 |
| - | |
1664 |
| - | |
| 1655 | + | |
1665 | 1656 |
| |
1666 |
| - | |
| 1657 | + | |
1667 | 1658 |
| |
1668 |
| - | |
1669 |
| - | |
1670 |
| - | |
| 1659 | + | |
| 1660 | + | |
1671 | 1661 |
| |
1672 | 1662 |
| |
1673 | 1663 |
| |
1674 | 1664 |
| |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
1675 | 1671 |
| |
1676 | 1672 |
| |
1677 | 1673 |
| |
1678 | 1674 |
| |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
1679 | 1688 |
| |
1680 | 1689 |
| |
1681 | 1690 |
| |
|
Lines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
501 | 501 |
| |
502 | 502 |
| |
503 | 503 |
| |
504 |
| - | |
505 | 504 |
| |
506 | 505 |
| |
507 | 506 |
| |
|
Lines changed: 0 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
108 | 108 |
| |
109 | 109 |
| |
110 | 110 |
| |
111 |
| - | |
112 |
| - | |
113 |
| - | |
114 |
| - | |
115 |
| - | |
116 |
| - | |
117 |
| - | |
118 |
| - | |
119 |
| - | |
120 | 111 |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
121 | 121 |
| |
122 | 122 |
| |
123 | 123 |
| |
| 124 | + | |
124 | 125 |
| |
125 | 126 |
| |
126 | 127 |
| |
|
0 commit comments
Comments
(0)