oracle-sql-parser 0.9.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +213 -0
- data/LICENSE.txt +21 -0
- data/README.md +66 -3
- data/Rakefile +62 -10
- data/lib/oracle-sql-parser/ast/fetch.rb +12 -0
- data/lib/oracle-sql-parser/ast/number_literal.rb +1 -1
- data/lib/oracle-sql-parser/ast/offset.rb +11 -0
- data/lib/oracle-sql-parser/ast/row_limiting_clause.rb +10 -0
- data/lib/oracle-sql-parser/ast/subquery.rb +8 -4
- data/lib/oracle-sql-parser/ast.rb +3 -0
- data/lib/oracle-sql-parser/grammar/condition/between.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/comparison.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/comparison.treetop +1 -0
- data/lib/oracle-sql-parser/grammar/condition/compound.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/exists.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/floating_point.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/in.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/is_of_type.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/multiset.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/null.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition/pattern_matching.rb +5 -3
- data/lib/oracle-sql-parser/grammar/condition.rb +5 -3
- data/lib/oracle-sql-parser/grammar/delete.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression/case.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression/compound.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression/cursor.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression/datetime.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression/function.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression/interval.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression/simple.rb +5 -3
- data/lib/oracle-sql-parser/grammar/expression.rb +5 -27
- data/lib/oracle-sql-parser/grammar/expression.treetop +0 -4
- data/lib/oracle-sql-parser/grammar/grammar.rb +5 -29
- data/lib/oracle-sql-parser/grammar/grammar.treetop +0 -8
- data/lib/oracle-sql-parser/grammar/insert.rb +5 -3
- data/lib/oracle-sql-parser/grammar/reserved_word.rb +662 -42
- data/lib/oracle-sql-parser/grammar/reserved_word.treetop +1150 -0
- data/lib/oracle-sql-parser/grammar/reserved_word_generator.rb +7 -1
- data/lib/oracle-sql-parser/grammar/select/for_update.rb +5 -3
- data/lib/oracle-sql-parser/grammar/select/group.rb +5 -3
- data/lib/oracle-sql-parser/grammar/select/join.rb +5 -3
- data/lib/oracle-sql-parser/grammar/select/order.rb +5 -3
- data/lib/oracle-sql-parser/grammar/select/query_block.rb +5 -3
- data/lib/oracle-sql-parser/grammar/select/row_limit.rb +407 -0
- data/lib/oracle-sql-parser/grammar/select/row_limit.treetop +49 -0
- data/lib/oracle-sql-parser/grammar/select/union.rb +5 -3
- data/lib/oracle-sql-parser/grammar/select.rb +46 -5
- data/lib/oracle-sql-parser/grammar/select.treetop +4 -1
- data/lib/oracle-sql-parser/grammar/update.rb +5 -3
- data/lib/oracle-sql-parser/grammar.rb +1 -0
- data/lib/oracle-sql-parser/version.rb +1 -1
- data/oracle-sql-parser.gemspec +14 -12
- metadata +40 -53
- data/.gitignore +0 -24
- data/Gemfile +0 -4
- data/HISTORY.md +0 -70
|
@@ -62,7 +62,7 @@ module OracleSqlParser
|
|
|
62
62
|
def self.generate_grammer_string(filename)
|
|
63
63
|
header = <<EOS
|
|
64
64
|
#
|
|
65
|
-
# #{File.basename(filename)} generated by
|
|
65
|
+
# #{File.basename(filename)} is generated by reserved_word_generator.rb. Do not edit.
|
|
66
66
|
#
|
|
67
67
|
module OracleSqlParser::Grammar
|
|
68
68
|
grammar ReservedWord
|
|
@@ -130,6 +130,7 @@ EOS
|
|
|
130
130
|
'ESCAPE',
|
|
131
131
|
'EXCLUSIVE',
|
|
132
132
|
'EXISTS',
|
|
133
|
+
'FETCH',
|
|
133
134
|
'FILE',
|
|
134
135
|
'FIRST',
|
|
135
136
|
'FLOAT',
|
|
@@ -173,6 +174,7 @@ EOS
|
|
|
173
174
|
'NAN',
|
|
174
175
|
'NATURAL',
|
|
175
176
|
'NESTED_TABLE_ID',
|
|
177
|
+
'NEXT',
|
|
176
178
|
'NEXTVAL',
|
|
177
179
|
'NOAUDIT',
|
|
178
180
|
'NOCOMPRESS',
|
|
@@ -183,6 +185,7 @@ EOS
|
|
|
183
185
|
'NUMBER',
|
|
184
186
|
'OF',
|
|
185
187
|
'OFFLINE',
|
|
188
|
+
'OFFSET',
|
|
186
189
|
'ON',
|
|
187
190
|
'ONLINE',
|
|
188
191
|
'ONLY',
|
|
@@ -191,6 +194,7 @@ EOS
|
|
|
191
194
|
'ORDER',
|
|
192
195
|
'OUTER',
|
|
193
196
|
'PCTFREE',
|
|
197
|
+
'PERCENT',
|
|
194
198
|
'PRIOR',
|
|
195
199
|
'PRIVILEGES',
|
|
196
200
|
'PUBLIC',
|
|
@@ -222,6 +226,7 @@ EOS
|
|
|
222
226
|
'SYSTIMESTAMP',
|
|
223
227
|
'TABLE',
|
|
224
228
|
'THEN',
|
|
229
|
+
'TIES',
|
|
225
230
|
'TIME',
|
|
226
231
|
'TO',
|
|
227
232
|
'TRIGGER',
|
|
@@ -241,6 +246,7 @@ EOS
|
|
|
241
246
|
'WHEN',
|
|
242
247
|
'WHENEVER',
|
|
243
248
|
'WHERE',
|
|
249
|
+
'WITH',
|
|
244
250
|
'YEAR',
|
|
245
251
|
'ZONE',
|
|
246
252
|
]
|
|
@@ -528,10 +528,12 @@ module OracleSqlParser::Grammar::Select
|
|
|
528
528
|
r0
|
|
529
529
|
end
|
|
530
530
|
|
|
531
|
-
end
|
|
532
531
|
|
|
533
|
-
|
|
534
|
-
|
|
532
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
533
|
+
include ForUpdate
|
|
534
|
+
end
|
|
535
535
|
end
|
|
536
536
|
|
|
537
|
+
(remove_const(:ForUpdateParser) if const_defined?(:ForUpdateParser)) rescue nil; ForUpdateParser = ForUpdate::Parser
|
|
538
|
+
|
|
537
539
|
end
|
|
@@ -386,10 +386,12 @@ module OracleSqlParser::Grammar::Select
|
|
|
386
386
|
r0
|
|
387
387
|
end
|
|
388
388
|
|
|
389
|
-
end
|
|
390
389
|
|
|
391
|
-
|
|
392
|
-
|
|
390
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
391
|
+
include Group
|
|
392
|
+
end
|
|
393
393
|
end
|
|
394
394
|
|
|
395
|
+
(remove_const(:GroupParser) if const_defined?(:GroupParser)) rescue nil; GroupParser = Group::Parser
|
|
396
|
+
|
|
395
397
|
end
|
|
@@ -1065,10 +1065,12 @@ module OracleSqlParser::Grammar::Select
|
|
|
1065
1065
|
r0
|
|
1066
1066
|
end
|
|
1067
1067
|
|
|
1068
|
-
end
|
|
1069
1068
|
|
|
1070
|
-
|
|
1071
|
-
|
|
1069
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
1070
|
+
include Join
|
|
1071
|
+
end
|
|
1072
1072
|
end
|
|
1073
1073
|
|
|
1074
|
+
(remove_const(:JoinParser) if const_defined?(:JoinParser)) rescue nil; JoinParser = Join::Parser
|
|
1075
|
+
|
|
1074
1076
|
end
|
|
@@ -389,10 +389,12 @@ module OracleSqlParser::Grammar::Select
|
|
|
389
389
|
r0
|
|
390
390
|
end
|
|
391
391
|
|
|
392
|
-
end
|
|
393
392
|
|
|
394
|
-
|
|
395
|
-
|
|
393
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
394
|
+
include Order
|
|
395
|
+
end
|
|
396
396
|
end
|
|
397
397
|
|
|
398
|
+
(remove_const(:OrderParser) if const_defined?(:OrderParser)) rescue nil; OrderParser = Order::Parser
|
|
399
|
+
|
|
398
400
|
end
|
|
@@ -951,10 +951,12 @@ module OracleSqlParser::Grammar::Select
|
|
|
951
951
|
r0
|
|
952
952
|
end
|
|
953
953
|
|
|
954
|
-
end
|
|
955
954
|
|
|
956
|
-
|
|
957
|
-
|
|
955
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
956
|
+
include QueryBlock
|
|
957
|
+
end
|
|
958
958
|
end
|
|
959
959
|
|
|
960
|
+
(remove_const(:QueryBlockParser) if const_defined?(:QueryBlockParser)) rescue nil; QueryBlockParser = QueryBlock::Parser
|
|
961
|
+
|
|
960
962
|
end
|
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
# Autogenerated from a Treetop grammar. Edits may be lost.
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
module OracleSqlParser::Grammar::Select
|
|
5
|
+
module RowLimit
|
|
6
|
+
include Treetop::Runtime
|
|
7
|
+
|
|
8
|
+
def root
|
|
9
|
+
@root ||= :row_limiting_clause
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module RowLimitingClause0
|
|
13
|
+
def fetch
|
|
14
|
+
elements[0]
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
module RowLimitingClause1
|
|
19
|
+
def ast
|
|
20
|
+
OracleSqlParser::Ast::RowLimitingClause[
|
|
21
|
+
:fetch => fetch.ast
|
|
22
|
+
]
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def _nt_row_limiting_clause
|
|
27
|
+
start_index = index
|
|
28
|
+
if node_cache[:row_limiting_clause].has_key?(index)
|
|
29
|
+
cached = node_cache[:row_limiting_clause][index]
|
|
30
|
+
if cached
|
|
31
|
+
node_cache[:row_limiting_clause][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
|
32
|
+
@index = cached.interval.end
|
|
33
|
+
end
|
|
34
|
+
return cached
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
i0, s0 = index, []
|
|
38
|
+
r1 = _nt_fetch
|
|
39
|
+
s0 << r1
|
|
40
|
+
if s0.last
|
|
41
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
|
42
|
+
r0.extend(RowLimitingClause0)
|
|
43
|
+
r0.extend(RowLimitingClause1)
|
|
44
|
+
else
|
|
45
|
+
@index = i0
|
|
46
|
+
r0 = nil
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
node_cache[:row_limiting_clause][start_index] = r0
|
|
50
|
+
|
|
51
|
+
r0
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
module Offset0
|
|
55
|
+
def offset_keyword
|
|
56
|
+
elements[0]
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def space1
|
|
60
|
+
elements[1]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def offset
|
|
64
|
+
elements[2]
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def space2
|
|
68
|
+
elements[3]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def row
|
|
72
|
+
elements[4]
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
module Offset1
|
|
77
|
+
def ast
|
|
78
|
+
OracleSqlParser::Ast::Offset[
|
|
79
|
+
:offset_keyword => offset_keyword,
|
|
80
|
+
:offset => offset,
|
|
81
|
+
:row_keyword => row.try(:row_keyword),
|
|
82
|
+
:rows_keyword => row.try(:rows_keyword),
|
|
83
|
+
]
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def _nt_offset
|
|
88
|
+
start_index = index
|
|
89
|
+
if node_cache[:offset].has_key?(index)
|
|
90
|
+
cached = node_cache[:offset][index]
|
|
91
|
+
if cached
|
|
92
|
+
node_cache[:offset][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
|
93
|
+
@index = cached.interval.end
|
|
94
|
+
end
|
|
95
|
+
return cached
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
i0, s0 = index, []
|
|
99
|
+
r1 = _nt_offset_keyword
|
|
100
|
+
s0 << r1
|
|
101
|
+
if r1
|
|
102
|
+
r2 = _nt_space
|
|
103
|
+
s0 << r2
|
|
104
|
+
if r2
|
|
105
|
+
r3 = _nt_number_literal
|
|
106
|
+
s0 << r3
|
|
107
|
+
if r3
|
|
108
|
+
r4 = _nt_space
|
|
109
|
+
s0 << r4
|
|
110
|
+
if r4
|
|
111
|
+
i5 = index
|
|
112
|
+
r6 = _nt_row_keyword
|
|
113
|
+
if r6
|
|
114
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
|
115
|
+
r5 = r6
|
|
116
|
+
else
|
|
117
|
+
r7 = _nt_rows_keyword
|
|
118
|
+
if r7
|
|
119
|
+
r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
|
|
120
|
+
r5 = r7
|
|
121
|
+
else
|
|
122
|
+
@index = i5
|
|
123
|
+
r5 = nil
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
s0 << r5
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
if s0.last
|
|
132
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
|
133
|
+
r0.extend(Offset0)
|
|
134
|
+
r0.extend(Offset1)
|
|
135
|
+
else
|
|
136
|
+
@index = i0
|
|
137
|
+
r0 = nil
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
node_cache[:offset][start_index] = r0
|
|
141
|
+
|
|
142
|
+
r0
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
module Fetch0
|
|
146
|
+
def rowcount
|
|
147
|
+
elements[0]
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
module Fetch1
|
|
152
|
+
def percentage
|
|
153
|
+
elements[0]
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def percentage_keyword
|
|
157
|
+
elements[1]
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
module Fetch2
|
|
162
|
+
def only_keyword
|
|
163
|
+
elements[0]
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
module Fetch3
|
|
168
|
+
def with_keyword
|
|
169
|
+
elements[0]
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def space
|
|
173
|
+
elements[1]
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def ties_keyword
|
|
177
|
+
elements[2]
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
module Fetch4
|
|
182
|
+
def fetch_keyword
|
|
183
|
+
elements[0]
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def space1
|
|
187
|
+
elements[1]
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def first
|
|
191
|
+
elements[2]
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def space2
|
|
195
|
+
elements[3]
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def rowcount
|
|
199
|
+
elements[4]
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def space3
|
|
203
|
+
elements[5]
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def rows
|
|
207
|
+
elements[6]
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def space4
|
|
211
|
+
elements[7]
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def only
|
|
215
|
+
elements[8]
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
module Fetch5
|
|
220
|
+
def ast
|
|
221
|
+
OracleSqlParser::Ast::Fetch[
|
|
222
|
+
fetch: fetch_keyword.ast,
|
|
223
|
+
first: first.ast,
|
|
224
|
+
rowcount: rowcount.try(:rowcount).ast,
|
|
225
|
+
percentage: rowcount.try(:percentage).ast,
|
|
226
|
+
percentage_keyword: rowcount.try(:percentage_keyword).ast,
|
|
227
|
+
rows: rows.ast,
|
|
228
|
+
only: only.try(:only_keyword).ast,
|
|
229
|
+
with: only.try(:with_keyword).ast,
|
|
230
|
+
ties: only.try(:ties_keyword).ast,
|
|
231
|
+
]
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def _nt_fetch
|
|
236
|
+
start_index = index
|
|
237
|
+
if node_cache[:fetch].has_key?(index)
|
|
238
|
+
cached = node_cache[:fetch][index]
|
|
239
|
+
if cached
|
|
240
|
+
node_cache[:fetch][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
|
241
|
+
@index = cached.interval.end
|
|
242
|
+
end
|
|
243
|
+
return cached
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
i0, s0 = index, []
|
|
247
|
+
r1 = _nt_fetch_keyword
|
|
248
|
+
s0 << r1
|
|
249
|
+
if r1
|
|
250
|
+
r2 = _nt_space
|
|
251
|
+
s0 << r2
|
|
252
|
+
if r2
|
|
253
|
+
i3 = index
|
|
254
|
+
r4 = _nt_first_keyword
|
|
255
|
+
if r4
|
|
256
|
+
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
|
257
|
+
r3 = r4
|
|
258
|
+
else
|
|
259
|
+
r5 = _nt_next_keyword
|
|
260
|
+
if r5
|
|
261
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
|
262
|
+
r3 = r5
|
|
263
|
+
else
|
|
264
|
+
@index = i3
|
|
265
|
+
r3 = nil
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
s0 << r3
|
|
269
|
+
if r3
|
|
270
|
+
r6 = _nt_space
|
|
271
|
+
s0 << r6
|
|
272
|
+
if r6
|
|
273
|
+
i7 = index
|
|
274
|
+
i8, s8 = index, []
|
|
275
|
+
r9 = _nt_integer
|
|
276
|
+
s8 << r9
|
|
277
|
+
if s8.last
|
|
278
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
|
279
|
+
r8.extend(Fetch0)
|
|
280
|
+
else
|
|
281
|
+
@index = i8
|
|
282
|
+
r8 = nil
|
|
283
|
+
end
|
|
284
|
+
if r8
|
|
285
|
+
r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
|
|
286
|
+
r7 = r8
|
|
287
|
+
else
|
|
288
|
+
i10, s10 = index, []
|
|
289
|
+
r11 = _nt_integer
|
|
290
|
+
s10 << r11
|
|
291
|
+
if r11
|
|
292
|
+
r12 = _nt_percentage_keyword
|
|
293
|
+
s10 << r12
|
|
294
|
+
end
|
|
295
|
+
if s10.last
|
|
296
|
+
r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
|
|
297
|
+
r10.extend(Fetch1)
|
|
298
|
+
else
|
|
299
|
+
@index = i10
|
|
300
|
+
r10 = nil
|
|
301
|
+
end
|
|
302
|
+
if r10
|
|
303
|
+
r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
|
|
304
|
+
r7 = r10
|
|
305
|
+
else
|
|
306
|
+
@index = i7
|
|
307
|
+
r7 = nil
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
s0 << r7
|
|
311
|
+
if r7
|
|
312
|
+
r13 = _nt_space
|
|
313
|
+
s0 << r13
|
|
314
|
+
if r13
|
|
315
|
+
i14 = index
|
|
316
|
+
r15 = _nt_row_keyword
|
|
317
|
+
if r15
|
|
318
|
+
r15 = SyntaxNode.new(input, (index-1)...index) if r15 == true
|
|
319
|
+
r14 = r15
|
|
320
|
+
else
|
|
321
|
+
r16 = _nt_rows_keyword
|
|
322
|
+
if r16
|
|
323
|
+
r16 = SyntaxNode.new(input, (index-1)...index) if r16 == true
|
|
324
|
+
r14 = r16
|
|
325
|
+
else
|
|
326
|
+
@index = i14
|
|
327
|
+
r14 = nil
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
s0 << r14
|
|
331
|
+
if r14
|
|
332
|
+
r17 = _nt_space
|
|
333
|
+
s0 << r17
|
|
334
|
+
if r17
|
|
335
|
+
i18 = index
|
|
336
|
+
i19, s19 = index, []
|
|
337
|
+
r20 = _nt_only_keyword
|
|
338
|
+
s19 << r20
|
|
339
|
+
if s19.last
|
|
340
|
+
r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
|
|
341
|
+
r19.extend(Fetch2)
|
|
342
|
+
else
|
|
343
|
+
@index = i19
|
|
344
|
+
r19 = nil
|
|
345
|
+
end
|
|
346
|
+
if r19
|
|
347
|
+
r19 = SyntaxNode.new(input, (index-1)...index) if r19 == true
|
|
348
|
+
r18 = r19
|
|
349
|
+
else
|
|
350
|
+
i21, s21 = index, []
|
|
351
|
+
r22 = _nt_with_keyword
|
|
352
|
+
s21 << r22
|
|
353
|
+
if r22
|
|
354
|
+
r23 = _nt_space
|
|
355
|
+
s21 << r23
|
|
356
|
+
if r23
|
|
357
|
+
r24 = _nt_ties_keyword
|
|
358
|
+
s21 << r24
|
|
359
|
+
end
|
|
360
|
+
end
|
|
361
|
+
if s21.last
|
|
362
|
+
r21 = instantiate_node(SyntaxNode,input, i21...index, s21)
|
|
363
|
+
r21.extend(Fetch3)
|
|
364
|
+
else
|
|
365
|
+
@index = i21
|
|
366
|
+
r21 = nil
|
|
367
|
+
end
|
|
368
|
+
if r21
|
|
369
|
+
r21 = SyntaxNode.new(input, (index-1)...index) if r21 == true
|
|
370
|
+
r18 = r21
|
|
371
|
+
else
|
|
372
|
+
@index = i18
|
|
373
|
+
r18 = nil
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
s0 << r18
|
|
377
|
+
end
|
|
378
|
+
end
|
|
379
|
+
end
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
end
|
|
383
|
+
end
|
|
384
|
+
end
|
|
385
|
+
if s0.last
|
|
386
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
|
387
|
+
r0.extend(Fetch4)
|
|
388
|
+
r0.extend(Fetch5)
|
|
389
|
+
else
|
|
390
|
+
@index = i0
|
|
391
|
+
r0 = nil
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
node_cache[:fetch][start_index] = r0
|
|
395
|
+
|
|
396
|
+
r0
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
401
|
+
include RowLimit
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
(remove_const(:RowLimitParser) if const_defined?(:RowLimitParser)) rescue nil; RowLimitParser = RowLimit::Parser
|
|
406
|
+
|
|
407
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module OracleSqlParser::Grammar::Select
|
|
2
|
+
grammar RowLimit
|
|
3
|
+
rule row_limiting_clause
|
|
4
|
+
fetch:fetch {
|
|
5
|
+
def ast
|
|
6
|
+
OracleSqlParser::Ast::RowLimitingClause[
|
|
7
|
+
:fetch => fetch.ast
|
|
8
|
+
]
|
|
9
|
+
end
|
|
10
|
+
}
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
rule offset
|
|
14
|
+
offset_keyword space offset:number_literal space row:(row_keyword / rows_keyword) {
|
|
15
|
+
def ast
|
|
16
|
+
OracleSqlParser::Ast::Offset[
|
|
17
|
+
:offset_keyword => offset_keyword,
|
|
18
|
+
:offset => offset,
|
|
19
|
+
:row_keyword => row.try(:row_keyword),
|
|
20
|
+
:rows_keyword => row.try(:rows_keyword),
|
|
21
|
+
]
|
|
22
|
+
end
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
rule fetch
|
|
27
|
+
fetch_keyword space
|
|
28
|
+
first:(first_keyword / next_keyword) space
|
|
29
|
+
rowcount:(rowcount:integer / percentage:integer percentage_keyword) space
|
|
30
|
+
rows:(row_keyword / rows_keyword) space
|
|
31
|
+
only:(only_keyword:only_keyword / with_keyword:with_keyword space ties_keyword:ties_keyword)
|
|
32
|
+
{
|
|
33
|
+
def ast
|
|
34
|
+
OracleSqlParser::Ast::Fetch[
|
|
35
|
+
fetch: fetch_keyword.ast,
|
|
36
|
+
first: first.ast,
|
|
37
|
+
rowcount: rowcount.try(:rowcount).ast,
|
|
38
|
+
percentage: rowcount.try(:percentage).ast,
|
|
39
|
+
percentage_keyword: rowcount.try(:percentage_keyword).ast,
|
|
40
|
+
rows: rows.ast,
|
|
41
|
+
only: only.try(:only_keyword).ast,
|
|
42
|
+
with: only.try(:with_keyword).ast,
|
|
43
|
+
ties: only.try(:ties_keyword).ast,
|
|
44
|
+
]
|
|
45
|
+
end
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -299,10 +299,12 @@ module OracleSqlParser::Grammar::Select
|
|
|
299
299
|
r0
|
|
300
300
|
end
|
|
301
301
|
|
|
302
|
-
end
|
|
303
302
|
|
|
304
|
-
|
|
305
|
-
|
|
303
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
304
|
+
include Union
|
|
305
|
+
end
|
|
306
306
|
end
|
|
307
307
|
|
|
308
|
+
(remove_const(:UnionParser) if const_defined?(:UnionParser)) rescue nil; UnionParser = Union::Parser
|
|
309
|
+
|
|
308
310
|
end
|
|
@@ -21,6 +21,8 @@ module OracleSqlParser::Grammar
|
|
|
21
21
|
|
|
22
22
|
include OracleSqlParser::Grammar::Select::QueryBlock
|
|
23
23
|
|
|
24
|
+
include OracleSqlParser::Grammar::Select::RowLimit
|
|
25
|
+
|
|
24
26
|
module SelectStatement0
|
|
25
27
|
def space
|
|
26
28
|
elements[0]
|
|
@@ -167,6 +169,16 @@ module OracleSqlParser::Grammar
|
|
|
167
169
|
end
|
|
168
170
|
|
|
169
171
|
module Subquery5
|
|
172
|
+
def space
|
|
173
|
+
elements[0]
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def row_limiting_clause
|
|
177
|
+
elements[1]
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
module Subquery6
|
|
170
182
|
def query
|
|
171
183
|
elements[0]
|
|
172
184
|
end
|
|
@@ -174,9 +186,13 @@ module OracleSqlParser::Grammar
|
|
|
174
186
|
def order
|
|
175
187
|
elements[1]
|
|
176
188
|
end
|
|
189
|
+
|
|
190
|
+
def row_limit
|
|
191
|
+
elements[2]
|
|
192
|
+
end
|
|
177
193
|
end
|
|
178
194
|
|
|
179
|
-
module
|
|
195
|
+
module Subquery7
|
|
180
196
|
def ast
|
|
181
197
|
OracleSqlParser::Ast::Subquery[
|
|
182
198
|
:has_parenthesis => query.try(:left_parenthesis) ? true : nil,
|
|
@@ -184,6 +200,7 @@ module OracleSqlParser::Grammar
|
|
|
184
200
|
:subqueries => query.try(:subqueries).ast,
|
|
185
201
|
:subquery => query.try(:subquery).ast,
|
|
186
202
|
:order_by_clause => order.try(:order_by_clause).ast,
|
|
203
|
+
:row_limiting_clause => row_limit.try(:row_limiting_clause).ast,
|
|
187
204
|
]
|
|
188
205
|
end
|
|
189
206
|
end
|
|
@@ -335,11 +352,33 @@ module OracleSqlParser::Grammar
|
|
|
335
352
|
r18 = instantiate_node(SyntaxNode,input, index...index)
|
|
336
353
|
end
|
|
337
354
|
s0 << r18
|
|
355
|
+
if r18
|
|
356
|
+
i23, s23 = index, []
|
|
357
|
+
r24 = _nt_space
|
|
358
|
+
s23 << r24
|
|
359
|
+
if r24
|
|
360
|
+
r25 = _nt_row_limiting_clause
|
|
361
|
+
s23 << r25
|
|
362
|
+
end
|
|
363
|
+
if s23.last
|
|
364
|
+
r23 = instantiate_node(SyntaxNode,input, i23...index, s23)
|
|
365
|
+
r23.extend(Subquery5)
|
|
366
|
+
else
|
|
367
|
+
@index = i23
|
|
368
|
+
r23 = nil
|
|
369
|
+
end
|
|
370
|
+
if r23
|
|
371
|
+
r22 = r23
|
|
372
|
+
else
|
|
373
|
+
r22 = instantiate_node(SyntaxNode,input, index...index)
|
|
374
|
+
end
|
|
375
|
+
s0 << r22
|
|
376
|
+
end
|
|
338
377
|
end
|
|
339
378
|
if s0.last
|
|
340
379
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
|
341
|
-
r0.extend(Subquery5)
|
|
342
380
|
r0.extend(Subquery6)
|
|
381
|
+
r0.extend(Subquery7)
|
|
343
382
|
else
|
|
344
383
|
@index = i0
|
|
345
384
|
r0 = nil
|
|
@@ -350,10 +389,12 @@ module OracleSqlParser::Grammar
|
|
|
350
389
|
r0
|
|
351
390
|
end
|
|
352
391
|
|
|
353
|
-
end
|
|
354
392
|
|
|
355
|
-
|
|
356
|
-
|
|
393
|
+
class Parser < Treetop::Runtime::CompiledParser
|
|
394
|
+
include Select
|
|
395
|
+
end
|
|
357
396
|
end
|
|
358
397
|
|
|
398
|
+
(remove_const(:SelectParser) if const_defined?(:SelectParser)) rescue nil; SelectParser = Select::Parser
|
|
399
|
+
|
|
359
400
|
end
|