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 7fba210 Support oracle alter partition grammar (#9940)
7fba210 is described below
commit 7fba21067b2ed8db4987af9e55e44b9a4c62340f
Author: Zhu jun <[email protected]>
AuthorDate: Fri Apr 9 11:47:55 2021 +0800
Support oracle alter partition grammar (#9940)
* add alter table partition grammer
* add testcase
* add empty line
* fix
* fix
* trigger ci
---
.../src/main/antlr4/imports/oracle/DDLStatement.g4 | 30 +++++++++++++++++++++-
.../src/main/resources/case/ddl/alter-table.xml | 11 ++++++++
.../src/main/resources/sql/supported/ddl/alter.xml | 6 +++--
3 files changed, 44 insertions(+), 3 deletions(-)
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 c2a8968..3e80491 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
@@ -240,7 +240,7 @@ tableAlias
;
alterDefinitionClause
- : (alterTableProperties | columnClauses | constraintClauses |
alterExternalTable)?
+ : (alterTableProperties | columnClauses | constraintClauses |
alterExternalTable | alterTablePartition)?
;
alterTableProperties
@@ -919,3 +919,31 @@ flashbackArchiveClause
alterSynonym
: ALTER PUBLIC? SYNONYM (schemaName DOT_)? synonymName (COMPILE |
EDITIONABLE | NONEDITIONABLE)
;
+
+alterTablePartition
+ : addTablePartition | dropTablePartition
+ ;
+
+addTablePartition
+ : ADD (addRangePartitionClause | addListPartitionClause)
+ ;
+
+addRangePartitionClause
+ : PARTITION partitionName? rangeValuesClause tablePartitionDescription
+ ((LP_? rangeSubpartitionDesc (COMMA_ rangeSubpartitionDesc)* |
listSubpartitionDesc (COMMA_ listSubpartitionDesc)* | individualHashSubparts
(COMMA_ individualHashSubparts)* RP_?)
+ | hashSubpartitionQuantity)?
+ ;
+
+addListPartitionClause
+ : PARTITION partitionName? listValuesClause tablePartitionDescription
+ ((LP_? rangeSubpartitionDesc (COMMA_ rangeSubpartitionDesc)* |
listSubpartitionDesc (COMMA_ listSubpartitionDesc)* | individualHashSubparts
(COMMA_ individualHashSubparts)* RP_?)
+ | hashSubpartitionQuantity)?
+ ;
+
+dropTablePartition
+ : DROP partitionExtendedNames
+ ;
+
+partitionExtendedNames
+ : (PARTITION | PARTITIONS) partition
+ ;
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/ddl/alter-table.xml
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/ddl/alter-table.xml
index 973fcab7..5db330a 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/ddl/alter-table.xml
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/case/ddl/alter-table.xml
@@ -1024,4 +1024,15 @@
</add-column>
</alter-table>
+ <alter-table sql-case-id="alter_table_add_range_partition">
+ <table name="t_order" start-index="12" stop-index="18"/>
+ </alter-table>
+
+ <alter-table sql-case-id="alter_table_add_list_partition">
+ <table name="t_order" start-index="12" stop-index="18"/>
+ </alter-table>
+
+ <alter-table sql-case-id="alter_table_drop_partition">
+ <table name="t_order" start-index="12" stop-index="18"/>
+ </alter-table>
</sql-parser-test-cases>
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/ddl/alter.xml
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/ddl/alter.xml
index 55368e9..26c9499 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/ddl/alter.xml
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-test/src/main/resources/sql/supported/ddl/alter.xml
@@ -122,7 +122,9 @@
<sql-case id="alter_table_with_enable_all_triggers" value="ALTER TABLE
t_log ADD name VARCHAR(10) ENABLE ALL TRIGGERS" db-types="Oracle" />
<sql-case id="alter_table_with_disable_container_map" value="ALTER TABLE
t_log ADD name VARCHAR(10) DISABLE CONTAINER_MAP" db-types="Oracle" />
<sql-case id="alter_table_with_disable_containers_default" value="ALTER
TABLE t_log ADD name VARCHAR(10) DISABLE CONTAINERS_DEFAULT" db-types="Oracle"
/>
-
+ <sql-case id="alter_table_add_range_partition" value="ALTER TABLE t_order
ADD PARTITION range_p_order VALUES LESS THAN(100)" db-types="Oracle" />
+ <sql-case id="alter_table_add_list_partition" value="ALTER TABLE t_order
ADD PARTITION list_p_order VALUES(100, 200, 300)" db-types="Oracle" />
+ <sql-case id="alter_table_drop_partition" value="ALTER TABLE t_order DROP
PARTITION list_p_order" db-types="Oracle" />
<!-- alter index test-->
<sql-case id="alter_index" value="ALTER INDEX order_index REBUILD
PARALLEL" db-types="Oracle" />
<sql-case id="alter_index_with_space" value=" ALTER INDEX
@@ -172,5 +174,5 @@
<!--alter synonym test-->
<sql-case id="alter_synonym_compile" value="ALTER SYNONYM offices COMPILE"
db-types="Oracle" />
<sql-case id="alter_public_synonym_compile" value="ALTER PUBLIC SYNONYM
emp_table COMPILE" db-types="Oracle" />
- <sql-case id="alter_synonym_noneditionable" value="ALTER SYNONYM offices
NONEDITIONABLE" db-types="Oracle" />
+ <sql-case id="alter_synonym_noneditionable" value="ALTER SYNONYM offices
NONEDITIONABLE" db-types="Oracle" />
</sql-cases>