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 425ee2d3d5
commit 112d215371
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,6 +82,10 @@ quotedString
} }
; ;
blankSpacesToSkip
: (newLineToSkip | spaceToSkip | tabToSkip)*
;
afterStatementPartNewline afterStatementPartNewline
: n:NEWLINE { : n:NEWLINE {
out( " " ); out( " " );
@ -87,6 +98,29 @@ newLineToSkip
} }
; ;
spaceToSkip
: SPACE {
skip();
}
;
tabToSkip
: TAB {
skip();
}
;
nonSkippedSpace
: s:SPACE {
out( s );
}
;
nonSkippedTab
: t:TAB {
out( t );
}
;
nonSkippedChar nonSkippedChar
: c:CHAR { : c:CHAR {
@ -124,8 +158,15 @@ protected
ESCqs : '\'' '\'' ; ESCqs : '\'' '\'' ;
CHAR CHAR
: ( ' ' | '\t' ) => ( ' ' | '\t' ) : ~( ';' | '\n' | '\r' | ' ' | '\t')
| ~( ';' | '\n' | '\r' ) ;
SPACE
: ' '
;
TAB
: '\t'
; ;
NEWLINE NEWLINE