@@ -61,6 +61,17 @@ def _change_splitlevel(self, ttype, value):
6161 return 1
6262 return 0
6363
64+ # Issue826: If we see a transaction keyword after BEGIN,
65+ # it's a transaction statement, not a block.
66+ if self ._seen_begin and \
67+ (ttype is T .Keyword or ttype is T .Name ) and \
68+ unified in ('TRANSACTION' , 'WORK' , 'TRAN' ,
69+ 'DISTRIBUTED' , 'DEFERRED' ,
70+ 'IMMEDIATE' , 'EXCLUSIVE' ):
71+ self ._begin_depth = max (0 , self ._begin_depth - 1 )
72+ self ._seen_begin = False
73+ return 0
74+
6475 # BEGIN and CASE/WHEN both end with END
6576 if unified == 'END' :
6677 if not self ._in_case :
@@ -121,7 +132,7 @@ def process(self, stream):
121132 self .consume_ws = True
122133 elif ttype is T .Keyword and value .split ()[0 ] == 'GO' :
123134 self .consume_ws = True
124- elif (ttype not in (T .Whitespace , T .Comment .Single ,
135+ elif (ttype not in (T .Whitespace , T .Newline , T . Comment .Single ,
125136 T .Comment .Multiline )
126137 and not (ttype is T .Keyword and value .upper () == 'BEGIN' )):
127138 # Reset _seen_begin if we see a non-whitespace, non-comment
0 commit comments