Module: OracleSqlParser::Grammar::Select

Includes:
ForUpdate, Group, Join, Order, QueryBlock, RowLimit, Union, Treetop::Runtime
Included in:
Grammar, SelectParser
Defined in:
lib/oracle-sql-parser/grammar/select.rb,
lib/oracle-sql-parser/grammar/select/join.rb,
lib/oracle-sql-parser/grammar/select/group.rb,
lib/oracle-sql-parser/grammar/select/order.rb,
lib/oracle-sql-parser/grammar/select/union.rb,
lib/oracle-sql-parser/grammar/select/row_limit.rb,
lib/oracle-sql-parser/grammar/select/for_update.rb,
lib/oracle-sql-parser/grammar/select/query_block.rb

Defined Under Namespace

Modules: ForUpdate, Group, Join, Order, QueryBlock, RowLimit, SelectStatement0, SelectStatement1, SelectStatement2, Subquery0, Subquery1, Subquery2, Subquery3, Subquery4, Subquery5, Subquery6, Subquery7, Union Classes: ForUpdateParser, GroupParser, JoinParser, OrderParser, QueryBlockParser, RowLimitParser, UnionParser

Instance Method Summary collapse

Methods included from RowLimit

#_nt_fetch, #_nt_offset, #_nt_row_limiting_clause

Methods included from QueryBlock

#_nt_model_clause, #_nt_query_block, #_nt_select_column, #_nt_select_list, #_nt_select_one, #_nt_select_source, #_nt_select_sources, #_nt_select_table, #_nt_subquery_factoring_clause

Methods included from Union

#_nt_subqueries_with_union, #_nt_union_all, #_nt_union_or_intersect_or_minus

Methods included from ForUpdate

#_nt_for_update_clause, #_nt_for_update_clause_column, #_nt_for_update_clause_columns

Methods included from Join

#_nt_column_list, #_nt_cross_join_clause, #_nt_cross_natural_join, #_nt_inner_cross_join_clause, #_nt_inner_join, #_nt_inner_join_clause, #_nt_join_clause, #_nt_on_clause, #_nt_on_or_using_clause, #_nt_outer_join_clause, #_nt_outer_join_type, #_nt_query_partition_clause, #_nt_using_clause

Methods included from Group

#_nt_group_by_clause, #_nt_group_column, #_nt_grouping_expression_list, #_nt_grouping_sets_clause, #_nt_rollup_cube_clause

Methods included from Order

#_nt_order_by_clause, #_nt_order_by_clause_item, #_nt_order_by_clause_items

Instance Method Details

#_nt_select_statementObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/oracle-sql-parser/grammar/select.rb', line 56

def _nt_select_statement
  start_index = index
  if node_cache[:select_statement].has_key?(index)
    cached = node_cache[:select_statement][index]
    if cached
      node_cache[:select_statement][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0, s0 = index, []
  r2 = _nt_space
  if r2
    r1 = r2
  else
    r1 = instantiate_node(SyntaxNode,input, index...index)
  end
  s0 << r1
  if r1
    r3 = _nt_subquery
    s0 << r3
    if r3
      i5, s5 = index, []
      r6 = _nt_space
      s5 << r6
      if r6
        r7 = _nt_for_update_clause
        s5 << r7
      end
      if s5.last
        r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
        r5.extend(SelectStatement0)
      else
        @index = i5
        r5 = nil
      end
      if r5
        r4 = r5
      else
        r4 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r4
      if r4
        r9 = _nt_space
        if r9
          r8 = r9
        else
          r8 = instantiate_node(SyntaxNode,input, index...index)
        end
        s0 << r8
      end
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(SelectStatement1)
    r0.extend(SelectStatement2)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:select_statement][start_index] = r0

  r0
end

#_nt_subqueryObject



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/oracle-sql-parser/grammar/select.rb', line 208

def _nt_subquery
  start_index = index
  if node_cache[:subquery].has_key?(index)
    cached = node_cache[:subquery][index]
    if cached
      node_cache[:subquery][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
      @index = cached.interval.end
    end
    return cached
  end

  i0, s0 = index, []
  i1 = index
  i2, s2 = index, []
  if (match_len = has_terminal?('(', false, index))
    r3 = true
    @index += match_len
  else
    terminal_parse_failure('\'(\'')
    r3 = nil
  end
  s2 << r3
  if r3
    r5 = _nt_space
    if r5
      r4 = r5
    else
      r4 = instantiate_node(SyntaxNode,input, index...index)
    end
    s2 << r4
    if r4
      r6 = _nt_subquery
      s2 << r6
      if r6
        r8 = _nt_space
        if r8
          r7 = r8
        else
          r7 = instantiate_node(SyntaxNode,input, index...index)
        end
        s2 << r7
        if r7
          if (match_len = has_terminal?(')', false, index))
            r9 = true
            @index += match_len
          else
            terminal_parse_failure('\')\'')
            r9 = nil
          end
          s2 << r9
        end
      end
    end
  end
  if s2.last
    r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
    r2.extend(Subquery0)
  else
    @index = i2
    r2 = nil
  end
  if r2
    r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
    r1 = r2
  else
    i10, s10 = index, []
    r11 = _nt_query_block
    s10 << r11
    if r11
      i12 = index
      i13, s13 = index, []
      r14 = _nt_space
      s13 << r14
      if r14
        r15 = _nt_union_or_intersect_or_minus
        s13 << r15
      end
      if s13.last
        r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
        r13.extend(Subquery1)
      else
        @index = i13
        r13 = nil
      end
      if r13
        @index = i12
        r12 = nil
        terminal_parse_failure("<a sequence>", true)
      else
        @terminal_failures.pop
        @index = i12
        r12 = instantiate_node(SyntaxNode,input, index...index)
      end
      s10 << r12
    end
    if s10.last
      r10 = instantiate_node(SyntaxNode,input, i10...index, s10)
      r10.extend(Subquery2)
    else
      @index = i10
      r10 = nil
    end
    if r10
      r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
      r1 = r10
    else
      i16, s16 = index, []
      r17 = _nt_subqueries_with_union
      s16 << r17
      if s16.last
        r16 = instantiate_node(SyntaxNode,input, i16...index, s16)
        r16.extend(Subquery3)
      else
        @index = i16
        r16 = nil
      end
      if r16
        r16 = SyntaxNode.new(input, (index-1)...index) if r16 == true
        r1 = r16
      else
        @index = i1
        r1 = nil
      end
    end
  end
  s0 << r1
  if r1
    i19, s19 = index, []
    r20 = _nt_space
    s19 << r20
    if r20
      r21 = _nt_order_by_clause
      s19 << r21
    end
    if s19.last
      r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
      r19.extend(Subquery4)
    else
      @index = i19
      r19 = nil
    end
    if r19
      r18 = r19
    else
      r18 = instantiate_node(SyntaxNode,input, index...index)
    end
    s0 << r18
    if r18
      i23, s23 = index, []
      r24 = _nt_space
      s23 << r24
      if r24
        r25 = _nt_row_limiting_clause
        s23 << r25
      end
      if s23.last
        r23 = instantiate_node(SyntaxNode,input, i23...index, s23)
        r23.extend(Subquery5)
      else
        @index = i23
        r23 = nil
      end
      if r23
        r22 = r23
      else
        r22 = instantiate_node(SyntaxNode,input, index...index)
      end
      s0 << r22
    end
  end
  if s0.last
    r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
    r0.extend(Subquery6)
    r0.extend(Subquery7)
  else
    @index = i0
    r0 = nil
  end

  node_cache[:subquery][start_index] = r0

  r0
end

#rootObject



8
9
10
# File 'lib/oracle-sql-parser/grammar/select.rb', line 8

def root
  @root ||= :select_statement
end