- Notifications
You must be signed in to change notification settings - Fork5
Commit0ea9efb
committed
Split psql's lexer into two separate .l files for SQL and backslash cases.
This gets us to a point where psqlscan.l can be used by other frontendprograms for the same purpose psql uses it for, ie to detect when it'scollected a complete SQL command from input that is divided acrossline boundaries. Moreover, other programs can supply their own lexersfor backslash commands of their own choosing. A follow-on patch willuse this in pgbench.The end result here is roughly the same as in Kyotaro Horiguchi's0001-Make-SQL-parser-part-of-psqlscan-independent-from-ps.patch, althoughthe details of the method for switching between lexers are quite different.Basically, in this patch we share the entire PsqlScanState, YY_BUFFER_STATEstack, *and* yyscan_t between different lexers. The only thing we needto do to switch to a different lexer is to make sure the start_state isvalid for the new lexer. This works because flex doesn't keep any otherpersistent state that depends on the specific lexing tables generated fora particular .l file. (We are assuming that both lexers are built withthe same flex version, or at least versions that are compatible withrespect to the contents of yyscan_t; but that doesn't seem likely tobe a big problem in practice, considering how slowly flex changes.)Aside from being more efficient than Horiguchi-san's original solution,this avoids possible corner-case changes in semantics: the original codewas capable of popping the input buffer stack while still staying inbackslash-related parsing states. I'm not sure that that equates to anyuseful user-visible behaviors, but I'm not sure it doesn't either, soI'm loath to assume that we only need to consider the topmost buffer whenparsing a backslash command.I've attempted to update the MSVC build scripts for the added .l file,but will rely on the buildfarm to see if I missed anything.Kyotaro Horiguchi and Tom Lane1 parent2719905 commit0ea9efb
File tree
12 files changed
+1005
-755
lines changed- src
- bin/psql
- tools/msvc
12 files changed
+1005
-755
lines changedLines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
| 2 | + | |
2 | 3 |
| |
3 | 4 |
| |
4 | 5 |
| |
|
Lines changed: 10 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
26 |
| - | |
| 26 | + | |
27 | 27 |
| |
28 | 28 |
| |
29 | 29 |
| |
| |||
47 | 47 |
| |
48 | 48 |
| |
49 | 49 |
| |
50 |
| - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
51 | 54 |
| |
52 | 55 |
| |
| 56 | + | |
53 | 57 |
| |
54 | 58 |
| |
55 |
| - | |
| 59 | + | |
56 | 60 |
| |
57 | 61 |
| |
58 | 62 |
| |
| |||
64 | 68 |
| |
65 | 69 |
| |
66 | 70 |
| |
67 |
| - | |
68 | 71 |
| |
69 | 72 |
| |
70 | 73 |
| |
| 74 | + | |
| 75 | + | |
71 | 76 |
| |
72 |
| - | |
| 77 | + |
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
45 | 45 |
| |
46 | 46 |
| |
47 | 47 |
| |
48 |
| - | |
| 48 | + | |
49 | 49 |
| |
50 | 50 |
| |
51 | 51 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2 | 2 |
| |
3 | 3 |
| |
4 | 4 |
| |
5 |
| - | |
| 5 | + | |
| 6 | + | |
6 | 7 |
| |
7 | 8 |
| |
8 | 9 |
| |
|
Lines changed: 2 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
25 | 25 |
| |
26 | 26 |
| |
27 | 27 |
| |
28 |
| - | |
29 |
| - | |
30 |
| - | |
31 |
| - | |
32 |
| - | |
33 |
| - | |
34 |
| - | |
35 |
| - | |
36 |
| - | |
37 |
| - | |
38 |
| - | |
39 | 28 |
| |
40 | 29 |
| |
41 | 30 |
| |
| |||
61 | 50 |
| |
62 | 51 |
| |
63 | 52 |
| |
64 |
| - | |
65 |
| - | |
66 |
| - | |
67 |
| - | |
68 |
| - | |
69 |
| - | |
70 |
| - | |
71 |
| - | |
| 53 | + | |
72 | 54 |
| |
73 |
| - | |
| 55 | + | |
74 | 56 |
| |
75 | 57 |
|
0 commit comments
Comments
(0)