Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix jjt
  • Loading branch information
jxnu-liguobin committed Dec 11, 2023
commit 17dda878d77c78bad7d2d4eab03f4906775da111
14 changes: 10 additions & 4 deletions src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -1224,13 +1224,14 @@ ShowIndexStatement ShowIndex(): {
}
}

RefreshMaterializedViewStatement RefreshMaterializedView(): {
Statement RefreshMaterializedView(): {
Table view = null;
boolean concurrently = false;
RefreshMode refreshMode = RefreshMode.DEFAULT;
List<String> captureRest;
}
{
<K_REFRESH> <K_MATERIALIZED> <K_VIEW>
<K_REFRESH> <K_MATERIALIZED> <K_VIEW>
[ LOOKAHEAD(2) <K_CONCURRENTLY> { concurrently = true; } ]
view = Table()
[
Expand All @@ -1239,9 +1240,14 @@ RefreshMaterializedViewStatement RefreshMaterializedView(): {
<K_NO> { refreshMode = RefreshMode.WITH_NO_DATA; }
]
<K_DATA>
]
]
captureRest = captureRest()
{
return new RefreshMaterializedViewStatement(view, concurrently, refreshMode);
if (concurrently && refreshMode == RefreshMode.WITH_NO_DATA) {
return new UnsupportedStatement("REFRESH", captureRest);
} else {
return new RefreshMaterializedViewStatement(view, concurrently, refreshMode);
}
}
}
// https://dev.mysql.com/doc/refman/8.0/en/show-tables.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
*/
package net.sf.jsqlparser.statement;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import net.sf.jsqlparser.JSQLParserException;
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
import net.sf.jsqlparser.statement.select.Select;
Expand All @@ -17,9 +20,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class UnsupportedStatementTest {
@Test
public void testSingleUnsupportedStatement() throws JSQLParserException {
Expand Down Expand Up @@ -88,6 +88,13 @@ void testAlter() throws JSQLParserException {
assertTrue(statement instanceof UnsupportedStatement);
}

@Test
void testRefresh() throws JSQLParserException {
String sqlStr = "REFRESH MATERIALIZED VIEW CONCURRENTLY my_view WITH NO DATA";
Statements statement = CCJSqlParserUtil.parseStatements(sqlStr);
assertTrue(statement.get(0) instanceof UnsupportedStatement);
}

@Test
void testCreate() throws JSQLParserException {
String sqlStr =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,5 +516,9 @@ void testRefreshMaterializedView() throws JSQLParserException {
String sqlStr5 = "REFRESH MATERIALIZED VIEW my_view WITH NO DATA";
Set<String> tableNames5 = TablesNamesFinder.findTables(sqlStr5);
assertThat(tableNames5).containsExactlyInAnyOrder("my_view");

String sqlStr6 = "REFRESH MATERIALIZED VIEW CONCURRENTLY my_view WITH NO DATA";
Set<String> tableNames6 = TablesNamesFinder.findTables(sqlStr6);
assertThat(tableNames6).isEmpty();
}
}