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/04/21 09:19:59 UTC
[shardingsphere] branch master updated: Complete Oracle drop table
partition grammar (#10052)
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 c09d7b0 Complete Oracle drop table partition grammar (#10052)
c09d7b0 is described below
commit c09d7b063377b006c4aa55e840fea5ca2b8eeec5
Author: Liangda-w <66...@users.noreply.github.com>
AuthorDate: Wed Apr 21 11:19:27 2021 +0200
Complete Oracle drop table partition grammar (#10052)
* Complete Oracle drop table partition grammar
* Change DOT to COMMA
* Add RP_
* Fix indexPartitionDesc
* Fix
* Fix oidIndexClause
---
.../src/main/antlr4/imports/oracle/BaseRule.g4 | 12 ++++
.../src/main/antlr4/imports/oracle/DDLStatement.g4 | 64 +++++++++++++++++++---
.../main/antlr4/imports/oracle/OracleKeyword.g4 | 10 +++-
.../src/main/resources/case/ddl/alter-table.xml | 24 ++++++++
.../src/main/resources/sql/supported/ddl/alter.xml | 6 ++
5 files changed, 106 insertions(+), 10 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 6d67dae..d6578f1 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
@@ -223,6 +223,10 @@ partitionSetName
: identifier
;
+partitionKeyValue
+ : NUMBER_ | dateTimeLiterals
+ ;
+
zonemapName
: identifier
;
@@ -259,6 +263,10 @@ collationName
: STRING_ | IDENTIFIER_
;
+columnCollationName
+ : identifier
+ ;
+
alias
: IDENTIFIER_
;
@@ -498,3 +506,7 @@ matchNone
hashSubpartitionQuantity
: NUMBER
;
+
+odciParameters
+ : identifier
+ ;
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 89cdb53..1973e8b 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
@@ -106,7 +106,7 @@ oidClause
;
oidIndexClause
- : OIDINDEX indexName? LP_ (physicalAttributesClause | TABLESPACE tablespaceName)+ RP_
+ : OIDINDEX indexName? LP_ (physicalAttributesClause | TABLESPACE tablespaceName)* RP_
;
createRelationalTableClause
@@ -280,7 +280,11 @@ tableAlias
;
alterDefinitionClause
- : (alterTableProperties | columnClauses | constraintClauses | alterExternalTable | alterTablePartition)?
+ : (alterTableProperties
+ | columnClauses
+ | constraintClauses
+ | alterTablePartitioning ((DEFERRED| IMMEDIATE) INVALIDATION)?
+ | alterExternalTable)?
;
alterTableProperties
@@ -459,7 +463,7 @@ rebuildClause
;
parallelClause
- : PARALLEL
+ : NOPARALLEL | PARALLEL NUMBER_?
;
usableSpecification
@@ -487,7 +491,7 @@ commitClause
;
physicalProperties
- : deferredSegmentCreation? segmentAttributesClause tableCompression? inmemoryTableClause? ilmClause?
+ : deferredSegmentCreation? segmentAttributesClause? tableCompression? inmemoryTableClause? ilmClause?
| deferredSegmentCreation? (organizationClause?|externalPartitionClause?)
| clusterClause
;
@@ -497,9 +501,9 @@ deferredSegmentCreation
;
segmentAttributesClause
- : physicalAttributesClause
+ : ( physicalAttributesClause
| (TABLESPACE tablespaceName | TABLESPACE SET tablespaceSetName)
- | loggingClause
+ | loggingClause)+
;
physicalAttributesClause
@@ -959,7 +963,7 @@ alterSynonym
: ALTER PUBLIC? SYNONYM (schemaName DOT_)? synonymName (COMPILE | EDITIONABLE | NONEDITIONABLE)
;
-alterTablePartition
+alterTablePartitioning
: addTablePartition | dropTablePartition
;
@@ -980,11 +984,53 @@ addListPartitionClause
;
dropTablePartition
- : DROP partitionExtendedNames
+ : DROP partitionExtendedNames (updateIndexClauses parallelClause?)?
;
partitionExtendedNames
- : (PARTITION | PARTITIONS) partition
+ : (PARTITION | PARTITIONS) (partitionName | partitionForClauses) (COMMA_ (partitionName | partitionForClauses))*
+ ;
+
+partitionForClauses
+ : FOR LP_ partitionKeyValue (COMMA_ partitionKeyValue)* RP_
+ ;
+
+updateIndexClauses
+ : updateGlobalIndexClause | updateAllIndexesClause
+ ;
+
+updateGlobalIndexClause
+ : (UPDATE | INVALIDATE) GLOBAL INDEXES
+ ;
+
+updateAllIndexesClause
+ : UPDATE INDEXES
+ (LP_ indexName LP_ (updateIndexPartition | updateIndexSubpartition) RP_
+ (COMMA_ indexName LP_ (updateIndexPartition | updateIndexSubpartition) RP_)* RP_)?
+ ;
+
+updateIndexPartition
+ : indexPartitionDesc indexSubpartitionClause?
+ (COMMA_ indexPartitionDesc indexSubpartitionClause?)*
+ ;
+
+indexPartitionDesc
+ : PARTITION
+ (partitionName
+ ((segmentAttributesClause | indexCompression)+ | PARAMETERS LP_ SQ_ odciParameters SQ_ RP_ )?
+ usableSpecification?
+ )?
+ ;
+
+indexSubpartitionClause
+ : STORE IN LP_ tablespaceName (COMMA_ tablespaceName)* RP_
+ | LP_ SUBPARTITION subpartitionName? (TABLESPACE tablespaceName)? indexCompression? usableSpecification?
+ (COMMA_ SUBPARTITION subpartitionName? (TABLESPACE tablespaceName)? indexCompression? usableSpecification?)* RP_
+ ;
+
+updateIndexSubpartition
+ : SUBPARTITION subpartitionName? (TABLESPACE tablespaceName)?
+ (COMMA_ SUBPARTITION subpartitionName? (TABLESPACE tablespaceName)?)*
;
supplementalLoggingProps
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 a98986d..e2cd895 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
@@ -903,6 +903,10 @@ PARALLEL
: P A R A L L E L
;
+NOPARALLEL
+ : N O P A R A L L E L
+ ;
+
LOG
: L O G
;
@@ -1180,7 +1184,7 @@ PCTTHRESHOLD
;
PARAMETERS
- : P A R A M E T E R S
+ : P A R A M E T E R S
;
LOCATION
@@ -1410,3 +1414,7 @@ EDITIONABLE
NONEDITIONABLE
: N O N E D I T I O N A B L E
;
+
+INDEXES
+ : I N D E X E S
+ ;
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 5db330a..a4696a5 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
@@ -1035,4 +1035,28 @@
<alter-table sql-case-id="alter_table_drop_partition">
<table name="t_order" start-index="12" stop-index="18"/>
</alter-table>
+
+ <alter-table sql-case-id="alter_table_drop_partition_update_global_index">
+ <table name="t_order" start-index="12" stop-index="18"/>
+ </alter-table>
+
+ <alter-table sql-case-id="alter_table_drop_partition_update_all_index">
+ <table name="t_order" start-index="12" stop-index="18"/>
+ </alter-table>
+
+ <alter-table sql-case-id="alter_table_drop_partition_update_all_index_partition">
+ <table name="t_order" start-index="12" stop-index="18"/>
+ </alter-table>
+
+ <alter-table sql-case-id="alter_table_drop_partition_update_all_index_subpartition">
+ <table name="t_order" start-index="12" stop-index="18"/>
+ </alter-table>
+
+ <alter-table sql-case-id="alter_table_drop_partition_update_global_index_parallel">
+ <table name="t_order" start-index="12" stop-index="18"/>
+ </alter-table>
+
+ <alter-table sql-case-id="alter_table_drop_partition_update_all_index_noparallel">
+ <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 26c9499..2c190a5 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
@@ -125,6 +125,12 @@
<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" />
+ <sql-case id="alter_table_drop_partition_update_global_index" value="ALTER TABLE t_order DROP PARTITION list_p_order UPDATE GLOBAL INDEXES" db-types="Oracle" />
+ <sql-case id="alter_table_drop_partition_update_all_index" value="ALTER TABLE t_order DROP PARTITION list_p_order UPDATE INDEXES" db-types="Oracle" />
+ <sql-case id="alter_table_drop_partition_update_all_index_partition" value="ALTER TABLE t_order DROP PARTITION list_p_order UPDATE INDEXES (order_index (PARTITION))" db-types="Oracle" />
+ <sql-case id="alter_table_drop_partition_update_all_index_subpartition" value="ALTER TABLE t_order DROP PARTITION list_p_order UPDATE INDEXES (order_index (SUBPARTITION))" db-types="Oracle" />
+ <sql-case id="alter_table_drop_partition_update_global_index_parallel" value="ALTER TABLE t_order DROP PARTITION list_p_order UPDATE GLOBAL INDEXES PARALLEL" db-types="Oracle" />
+ <sql-case id="alter_table_drop_partition_update_all_index_noparallel" value="ALTER TABLE t_order DROP PARTITION list_p_order UPDATE INDEXES NOPARALLEL" 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