You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2021/01/12 03:02:26 UTC
[shardingsphere] branch master updated: Support for create object
table in Oracle, for 6480 (#8988)
This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new a415be9 Support for create object table in Oracle,for 6480 (#8988)
a415be9 is described below
commit a415be91974a40fe32d685631eec3e069c4b6fdb
Author: coco <co...@gmail.com>
AuthorDate: Tue Jan 12 11:01:57 2021 +0800
Support for create object table in Oracle,for 6480 (#8988)
* refactor: support for creating private temporary, shared, duplicated table in Oracle.
* refactor: support for creating table with sharing, optimize, parent in Oracle.
* style: keep one empty line in the end of file.
* style: keep one empty line in the end of file.
* feat: support for create object table in Oracle.
---
.../src/main/antlr4/imports/oracle/BaseRule.g4 | 12 ++++++++----
.../src/main/antlr4/imports/oracle/DDLStatement.g4 | 20 ++++++++++++++++++--
.../src/main/antlr4/imports/oracle/OracleKeyword.g4 | 4 ++++
.../statement/impl/OracleDDLStatementSQLVisitor.java | 3 +++
.../src/main/resources/case/ddl/create-table.xml | 4 ++++
.../src/main/resources/sql/supported/ddl/create.xml | 1 +
6 files changed, 38 insertions(+), 6 deletions(-)
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/BaseRule.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/BaseRule.g4
index ed478ba..275057b 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/BaseRule.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/BaseRule.g4
@@ -111,6 +111,14 @@ columnName
: (owner DOT_)? name
;
+objectName
+ : (owner DOT_)? name
+ ;
+
+indexName
+ : identifier
+ ;
+
owner
: identifier
;
@@ -127,10 +135,6 @@ tableNames
: LP_? tableName (COMMA_ tableName)* RP_?
;
-indexName
- : identifier
- ;
-
oracleId
: IDENTIFIER_ | (STRING_ DOT_)* STRING_
;
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DDLStatement.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
index 4f954d3..d52760d 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
@@ -69,9 +69,9 @@ createSharingClause
;
createDefinitionClause
- : createRelationalTableClause
+ : createRelationalTableClause | createObjectTableClause
;
-
+
createRelationalTableClause
: (LP_ relationalProperties RP_)? (ON COMMIT (DELETE | PRESERVE) ROWS)?
;
@@ -84,6 +84,18 @@ createParentClause
: (PARENT tableName)?
;
+createObjectTableClause
+ : OF objectName objectTableSubstitution? (LP_ objectProperties RP_)? (ON COMMIT (DELETE | PRESERVE) ROWS)?
+ ;
+
+createMemOptimizeClause
+ : (MEMOPTIMIZE FOR READ)? (MEMOPTIMIZE FOR WRITE)?
+ ;
+
+createParentClause
+ : (PARENT tableName)?
+ ;
+
relationalProperties
: relationalProperty (COMMA_ relationalProperty)*
;
@@ -362,3 +374,7 @@ objectProperty
renameIndexClause
: (RENAME TO indexName)?
;
+
+objectTableSubstitution
+ : NOT? SUBSTITUTABLE AT ALL LEVELS
+ ;
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4 b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
index 64fd2f3..cf755fe 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
@@ -810,3 +810,7 @@ MEMOPTIMIZE
PARENT
: P A R E N T
;
+
+IDENTIFIER
+ : I D E N T I F I E R
+ ;
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java
index 58c54d7..11fabf3 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java
@@ -97,6 +97,9 @@ public final class OracleDDLStatementSQLVisitor extends OracleStatementSQLVisito
@Override
public ASTNode visitCreateDefinitionClause(final CreateDefinitionClauseContext ctx) {
CollectionValue<CreateDefinitionSegment> result = new CollectionValue<>();
+ if (null == ctx.createRelationalTableClause()) {
+ return result;
+ }
for (RelationalPropertyContext each : ctx.createRelationalTableClause().relationalProperties().relationalProperty()) {
if (null != each.columnDefinition()) {
result.getValue().add((ColumnDefinitionSegment) visit(each.columnDefinition()));
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/ddl/create-table.xml b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/ddl/create-table.xml
index a3f308a..af3a707 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/ddl/create-table.xml
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/ddl/create-table.xml
@@ -177,6 +177,10 @@
</column-definition>
</create-table>
+ <create-table sql-case-id="create_object_table">
+ <table name="t_log" start-index="13" stop-index="17" />
+ </create-table>
+
<create-table sql-case-id="create_local_temp_table">
<table name="t_temp_log" start-index="24" stop-index="33" />
<column-definition type="int" start-index="35" stop-index="40">
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/ddl/create.xml b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/ddl/create.xml
index 698e0b0..b15978d 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/ddl/create.xml
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/ddl/create.xml
@@ -33,6 +33,7 @@
<sql-case id="create_table_with_optimize_read" value="CREATE TABLE t_log(id int PRIMARY KEY, status varchar(10)) MEMOPTIMIZE FOR READ" db-types="Oracle" />
<sql-case id="create_table_with_optimize_write" value="CREATE TABLE t_log(id int PRIMARY KEY, status varchar(10)) MEMOPTIMIZE FOR WRITE" db-types="Oracle" />
<sql-case id="create_table_with_parent" value="CREATE TABLE t_log(id int PRIMARY KEY, status varchar(10)) PARENT t_log_parent" db-types="Oracle" />
+ <sql-case id="create_object_table" value="CREATE TABLE t_log OF t_log_type" db-types="Oracle" />
<sql-case id="create_local_temp_table" value="CREATE LOCAL TEMP TABLE t_temp_log(id int, status varchar(10))" db-types="PostgreSQL" />
<sql-case id="create_unlogged_table" value="CREATE UNLOGGED TABLE t_log(id int, status varchar(10))" db-types="PostgreSQL" />
<sql-case id="create_index" value="CREATE INDEX t_log_index ON t_log (id)" db-types="H2,MySQL,PostgreSQL,Oracle,SQLServer" />