@@ -1822,7 +1822,7 @@ private TableFilter readTablePrimary() {
18221822 schemaName = null ;
18231823 if (readIf (DOT )) {
18241824 tableName = readIdentifierWithSchema2 (tableName );
1825- } else if (!quoted && readIf (TABLE )) {
1825+ } else if (!quoted && readIf (TABLE , OPEN_PAREN )) {
18261826 table = readDataChangeDeltaTable (upperName (tableName ), backupIndex );
18271827 break label ;
18281828 }
@@ -1949,7 +1949,6 @@ private TableFilter buildTableFilter(Table table, String alias, ArrayList<String
19491949 }
19501950
19511951 private Table readDataChangeDeltaTable (String resultOptionName , int backupIndex ) {
1952- read (OPEN_PAREN );
19531952 int start = tokenIndex ;
19541953 DataChangeStatement statement ;
19551954 ResultOption resultOption = ResultOption .FINAL ;
@@ -5672,7 +5671,7 @@ private String readIdentifier() {
56725671 }
56735672
56745673 private void read (String expected ) {
5675- if (token . isQuoted () || ! equalsToken (expected , currentToken )) {
5674+ if (! testToken (expected , token )) {
56765675 addExpected (expected );
56775676 throw getSyntaxError ();
56785677 }
@@ -5688,14 +5687,34 @@ private void read(int tokenType) {
56885687 }
56895688
56905689 private boolean readIf (String tokenName ) {
5691- if (! token . isQuoted () && equalsToken ( tokenName , currentToken )) {
5690+ if (testToken ( tokenName , token )) {
56925691 read ();
56935692 return true ;
56945693 }
56955694 addExpected (tokenName );
56965695 return false ;
56975696 }
56985697
5698+ private boolean readIf (String tokenName1 , String tokenName2 ) {
5699+ int i = tokenIndex + 1 ;
5700+ if (i + 1 < tokens .size () && testToken (tokenName1 , token ) && testToken (tokenName2 , tokens .get (i ))) {
5701+ setTokenIndex (i + 1 );
5702+ return true ;
5703+ }
5704+ addExpected (tokenName1 , tokenName2 );
5705+ return false ;
5706+ }
5707+
5708+ private boolean readIf (String tokenName1 , int tokenType2 ) {
5709+ int i = tokenIndex + 1 ;
5710+ if (i + 1 < tokens .size () && tokens .get (i ).tokenType () == tokenType2 && testToken (tokenName1 , token )) {
5711+ setTokenIndex (i + 1 );
5712+ return true ;
5713+ }
5714+ addExpected (tokenName1 , TOKENS [tokenType2 ]);
5715+ return false ;
5716+ }
5717+
56995718 private boolean readIf (int tokenType ) {
57005719 if (tokenType == currentTokenType ) {
57015720 read ();
@@ -5706,10 +5725,9 @@ private boolean readIf(int tokenType) {
57065725 }
57075726
57085727 private boolean readIf (int tokenType1 , int tokenType2 ) {
5709- int size = tokens .size ();
57105728 if (tokenType1 == currentTokenType ) {
57115729 int i = tokenIndex + 1 ;
5712- if (i < size && tokens .get (i ).tokenType () == tokenType2 ) {
5730+ if (tokens .get (i ).tokenType () == tokenType2 ) {
57135731 setTokenIndex (i + 1 );
57145732 return true ;
57155733 }
@@ -5719,15 +5737,11 @@ private boolean readIf(int tokenType1, int tokenType2) {
57195737 }
57205738
57215739 private boolean readIf (int tokenType1 , String tokenName2 ) {
5722- int size = tokens .size ();
57235740 if (tokenType1 == currentTokenType ) {
57245741 int i = tokenIndex + 1 ;
5725- if (i < size ) {
5726- Token token2 = tokens .get (i );
5727- if (!token2 .isQuoted () && equalsToken (tokenName2 , token2 .asIdentifier ())) {
5728- setTokenIndex (i + 1 );
5729- return true ;
5730- }
5742+ if (testToken (tokenName2 , tokens .get (i ))) {
5743+ setTokenIndex (i + 1 );
5744+ return true ;
57315745 }
57325746 }
57335747 addExpected (TOKENS [tokenType1 ], tokenName2 );
@@ -5752,16 +5766,23 @@ private boolean readIf(Object... tokensTypesOrNames) {
57525766 }
57535767
57545768 private boolean isToken (String tokenName ) {
5755- if (! token . isQuoted () && equalsToken ( tokenName , currentToken )) {
5769+ if (testToken ( tokenName , token )) {
57565770 return true ;
57575771 }
57585772 addExpected (tokenName );
57595773 return false ;
57605774 }
57615775
57625776 private boolean testToken (Object expected , Token token ) {
5763- return expected instanceof Integer ? (int ) expected == token .tokenType ()
5764- : !token .isQuoted () && equalsToken ((String ) expected , token .asIdentifier ());
5777+ return expected instanceof Integer ? (int ) expected == token .tokenType () : testToken ((String ) expected , token );
5778+ }
5779+
5780+ private boolean testToken (String tokenName , Token token ) {
5781+ if (!token .isQuoted ()) {
5782+ String s = token .asIdentifier ();
5783+ return identifiersToUpper ? tokenName .equals (s ) : tokenName .equalsIgnoreCase (s );
5784+ }
5785+ return false ;
57655786 }
57665787
57675788 private boolean isToken (int tokenType ) {
0 commit comments