forked from opengaussexamples/examples
revise
This commit is contained in:
parent
baf06a4d43
commit
aa5c0f2343
|
|
@ -4,11 +4,9 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="d8d12963-4777-48e3-9669-309cf5e41d60" name="更改" comment="revise create table document">
|
||||
<list default="true" id="d8d12963-4777-48e3-9669-309cf5e41d60" name="更改" comment="revise">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/Generator/OpenGaussGenerator.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Generator/OpenGaussGenerator.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Main.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/Parser/AST/AlterTable/AlterAddColumnNode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Parser/AST/AlterTable/AlterAddColumnNode.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/Parser/OracleParser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Parser/OracleParser.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
|
|
@ -107,13 +105,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1723106789329</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00003" summary="AST node">
|
||||
<created>1723871742424</created>
|
||||
<option name="number" value="00003" />
|
||||
<option name="presentableId" value="LOCAL-00003" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1723871742424</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00004" summary="add AST node">
|
||||
<created>1723992163694</created>
|
||||
<option name="number" value="00004" />
|
||||
|
|
@ -450,7 +441,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1726154479052</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="52" />
|
||||
<task id="LOCAL-00052" summary="revise">
|
||||
<created>1726197698087</created>
|
||||
<option name="number" value="00052" />
|
||||
<option name="presentableId" value="LOCAL-00052" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1726197698087</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="53" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
|
@ -475,7 +473,6 @@
|
|||
<MESSAGE value="add pattern of functions in select" />
|
||||
<MESSAGE value="add some comments" />
|
||||
<MESSAGE value="add parseSelect" />
|
||||
<MESSAGE value="revise" />
|
||||
<MESSAGE value="add join pattern" />
|
||||
<MESSAGE value="add join class" />
|
||||
<MESSAGE value="add join" />
|
||||
|
|
@ -490,7 +487,8 @@
|
|||
<MESSAGE value="add alter table ast class" />
|
||||
<MESSAGE value="add alter table keywords" />
|
||||
<MESSAGE value="add alter table parser" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="add alter table parser" />
|
||||
<MESSAGE value="revise" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="revise" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<watches-manager>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public class Main {
|
|||
// " WHERE d.department_name = 'Sales'\n" +
|
||||
// ");";
|
||||
String sql = "ALTER TABLE employees ADD email VARCHAR2(100) Check (email != '12813@163.com');";
|
||||
// String sql = "ALTER TABLE employees ADD CONSTRAINT emp_pk PRIMARY KEY (employee_id);";
|
||||
OracleLexer lexer = new OracleLexer(sql);
|
||||
lexer.printTokens();
|
||||
OracleParser parser = new OracleParser(lexer);
|
||||
|
|
|
|||
|
|
@ -4,10 +4,7 @@ import Lexer.OracleLexer;
|
|||
import Lexer.Token;
|
||||
import Parser.AST.ASTNode;
|
||||
import Exception.ParseFailedException;
|
||||
import Parser.AST.AlterTable.AlterAddColumnNode;
|
||||
import Parser.AST.AlterTable.AlterEndNode;
|
||||
import Parser.AST.AlterTable.AlterNode;
|
||||
import Parser.AST.AlterTable.AlterObjNode;
|
||||
import Parser.AST.AlterTable.*;
|
||||
import Parser.AST.CaseWhen.CaseConditionNode;
|
||||
import Parser.AST.CaseWhen.CaseElseNode;
|
||||
import Parser.AST.CaseWhen.CaseEndNode;
|
||||
|
|
@ -955,8 +952,9 @@ public class OracleParser {
|
|||
else if (parseTokens.get(i).hasType(Token.TokenType.KEYWORD) && parseTokens.get(i).getValue().equalsIgnoreCase("ADD")) {
|
||||
// add column
|
||||
if (i + 1 < parseTokens.size() && parseTokens.get(i + 1).hasType(Token.TokenType.IDENTIFIER)) {
|
||||
i++;
|
||||
tokens = new ArrayList<>();
|
||||
tokens.add(parseTokens.get(i));
|
||||
i++;
|
||||
boolean state = false;
|
||||
AlterAddColumnNode child = new AlterAddColumnNode();
|
||||
child.setName(parseTokens.get(i));
|
||||
|
|
@ -1014,9 +1012,10 @@ public class OracleParser {
|
|||
}
|
||||
// add constraint
|
||||
else if (i + 1 < parseTokens.size() && parseTokens.get(i + 1).hasType(Token.TokenType.KEYWORD) && parseTokens.get(i + 1).getValue().equalsIgnoreCase("CONSTRAINT")) {
|
||||
i++;
|
||||
tokens = new ArrayList<>();
|
||||
tokens.add(parseTokens.get(i));
|
||||
i++;
|
||||
tokens.add(parseTokens.get(i));
|
||||
for (int j = i + 1; j < parseTokens.size(); j++) {
|
||||
/**
|
||||
* CONSTRAINT pk_example PRIMARY KEY (column1, column2)
|
||||
|
|
@ -1055,13 +1054,15 @@ public class OracleParser {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
if ((parseTokens.get(j).hasType(Token.TokenType.SYMBOL) && parseTokens.get(j).getValue().equals(",")) ||
|
||||
(parseTokens.get(j).hasType(Token.TokenType.SYMBOL) && parseTokens.get(j).getValue().equals(")")) ) {
|
||||
i = j;
|
||||
if ((parseTokens.get(j).hasType(Token.TokenType.SYMBOL) && parseTokens.get(j).getValue().equals(";"))) {
|
||||
i = j - 1;
|
||||
break;
|
||||
}
|
||||
tokens.add(parseTokens.get(j));
|
||||
}
|
||||
ASTNode childNode = new AlterAddConstraintNode(tokens);
|
||||
currentNode.addChild(childNode);
|
||||
currentNode = childNode;
|
||||
}
|
||||
// error sql
|
||||
else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue