HHH-14249 MultiLineImport fails when script contains blank spaces or tabs at the end of the last sql statement

This commit is contained in:
Andrea Boriero 2020-10-06 16:46:53 +01:00 committed by Sanne Grinovero
parent 79e6ffe483
commit c01718f735
2 changed files with 52 additions and 11 deletions

View File

@ -57,16 +57,23 @@ options {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
script script
: (newLineToSkip)* (statement)* EOF : blankSpacesToSkip (statement blankSpacesToSkip)* EOF
; ;
statement statement
: { statementStarted(); } (statementPart (afterStatementPartNewline)*)* DELIMITER (newLineToSkip)* { statementEnded(); } : { statementStarted(); } statementFirstPart (statementPart (afterStatementPartNewline)*)* DELIMITER { statementEnded(); }
;
statementFirstPart
: quotedString
| nonSkippedChar
; ;
statementPart statementPart
: quotedString : quotedString
| nonSkippedChar | nonSkippedChar
| nonSkippedSpace
| nonSkippedTab
; ;
quotedString quotedString
@ -75,11 +82,15 @@ quotedString
} }
; ;
blankSpacesToSkip
: (newLineToSkip | spaceToSkip | tabToSkip)*
;
afterStatementPartNewline afterStatementPartNewline
: n:NEWLINE { : n:NEWLINE {
out( " " ); out( " " );
} }
; ;
newLineToSkip newLineToSkip
: NEWLINE { : NEWLINE {
@ -87,11 +98,34 @@ newLineToSkip
} }
; ;
spaceToSkip
: SPACE {
skip();
}
;
tabToSkip
: TAB {
skip();
}
;
nonSkippedSpace
: s:SPACE {
out( s );
}
;
nonSkippedTab
: t:TAB {
out( t );
}
;
nonSkippedChar nonSkippedChar
: c:CHAR { : c:CHAR {
out( c ); out( c );
} }
; ;
@ -124,9 +158,16 @@ protected
ESCqs : '\'' '\'' ; ESCqs : '\'' '\'' ;
CHAR CHAR
: ( ' ' | '\t' ) => ( ' ' | '\t' ) : ~( ';' | '\n' | '\r' | ' ' | '\t')
| ~( ';' | '\n' | '\r' ) ;
;
SPACE
: ' '
;
TAB
: '\t'
;
NEWLINE NEWLINE
: ( '\r' | '\n' | '\r''\n' ) : ( '\r' | '\n' | '\r''\n' )