KonnexionsGmbH / sqlparse

LALR grammar based SQL Parser
Other
43 stars 15 forks source link

PL/SQL block: Fix contradictions between sqlparse and Oracle syntax #86

Closed walter-weinmann closed 6 years ago

walter-weinmann commented 7 years ago

This solves the issues #34. The new grammar definition is parse tree compatible with the existing grammar.


Oracle 12c grammar (simplified):

Oracle Database PL/SQL Language Reference

plsql_block ::= image

declare_section ::= image

body ::= image


Current sqlparse grammar:

procedure_call -> DECLARE BEGIN function_ref_list END                                           : {'declare begin procedure', '$3'}.
procedure_call -> DECLARE BEGIN sql_list          END                                           : {'declare begin procedure', '$3'}.
procedure_call ->         BEGIN function_ref_list END                                           : {'begin procedure', '$2'}.
procedure_call ->         BEGIN sql_list          END                                           : {'begin procedure', '$2'}.
procedure_call ->         CALL  function_ref                                                    : {'call procedure', '$2'}.

New sqlparse grammar:

procedure_call -> BEGIN function_ref_list END                                                   : {'begin procedure', '$2'}.
procedure_call -> BEGIN sql_list          END                                                   : {'begin procedure', '$2'}.
procedure_call -> CALL  function_ref                                                            : {'call procedure',  '$2'}.
walter-weinmann commented 6 years ago

Solved with PR #105.