This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang 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 0611ecd0265 Improve alter tablespace syntax rules (#28847)
0611ecd0265 is described below

commit 0611ecd0265bc64c8d3330f0a4fedf51336b44a7
Author: niu niu <[email protected]>
AuthorDate: Tue Oct 24 09:41:27 2023 +0800

    Improve alter tablespace syntax rules (#28847)
    
    * Improve alter tablespace syntax rules
    
    * Format code
---
 .../src/main/antlr4/imports/oracle/BaseRule.g4     |  8 ++++
 .../src/main/antlr4/imports/oracle/DDLStatement.g4 | 51 ++++++++++------------
 .../src/main/resources/case/ddl/alter-table.xml    |  4 ++
 .../main/resources/case/ddl/alter-tablespace.xml   | 12 +++++
 .../resources/sql/supported/ddl/alter-table.xml    |  1 +
 .../sql/supported/ddl/alter-tablespace.xml         |  3 ++
 6 files changed, 50 insertions(+), 29 deletions(-)

diff --git 
a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4 
b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
index 37696ef2cf3..0fcbec7659d 100644
--- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
+++ b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/BaseRule.g4
@@ -439,6 +439,10 @@ tablespaceName
     : identifier
     ;
 
+newTablespaceName
+    : identifier
+    ;
+
 subprogramName
     : identifier
     ;
@@ -1727,6 +1731,10 @@ filenamePattern
     : STRING_
     ;
 
+replacementFilenamePattern
+    : STRING_
+    ;
+
 connectString
     : STRING_
     ;
diff --git 
a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4 
b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
index beeacb52cb4..4a12a7e5335 100644
--- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
+++ b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
@@ -3922,7 +3922,7 @@ segmentManagementClause
     ;
 
 tablespaceGroupClause
-    : TABLESPACE GROUP tablespaceGroupName
+    : TABLESPACE GROUP (tablespaceGroupName | SQ_ SQ_)
     ;
 
 temporaryTablespaceClause
@@ -3958,12 +3958,13 @@ permanentTablespaceClause
 
 alterTablespace
     : ALTER TABLESPACE tablespaceName
-    ( MINIMUM EXTENT sizeClause
+    ( defaultTablespaceParams
+    | MINIMUM EXTENT sizeClause
     | RESIZE sizeClause
     | COALESCE
     | SHRINK SPACE (KEEP sizeClause)?
     | RENAME TO newTablespaceName
-    | (BEGIN|END) BACKUP
+    | (BEGIN | END) BACKUP
     | datafileTempfileClauses
     | tablespaceLoggingClauses
     | tablespaceGroupClause
@@ -3976,50 +3977,42 @@ alterTablespace
     )
     ;
 
-newTablespaceName
-    : identifier
+defaultTablespaceParams
+    : DEFAULT defaultTableCompression? defaultIndexCompression? 
inmemoryClause? ilmClause? storageClause?
     ;
 
-datafileTempfileClauses
-    : ADD (datafileSpecification | tempfileSpecification)
-    | DROP (DATAFILE | TEMPFILE) (fileSpecification | UNSIGNED_INTEGER) (KEEP 
sizeClause)?
-    | SHRINK TEMPFILE (fileSpecification | UNSIGNED_INTEGER) (KEEP sizeClause)?
-    | RENAME DATAFILE fileSpecification (COMMA_ fileSpecification)* TO 
fileSpecification (COMMA_ fileSpecification)*
-    | (DATAFILE | TEMPFILE) (ONLINE|OFFLINE)
+defaultTableCompression
+    : TABLE (COMPRESS FOR OLTP | COMPRESS FOR QUERY (LOW | HIGH) | COMPRESS 
FOR ARCHIVE (LOW | HIGH) | NOCOMPRESS)
     ;
 
-datafileSpecification
-    : DATAFILE
-      (COMMA_? datafileTempfileSpec)
+defaultIndexCompression
+    : INDEX (COMPRESS ADVANCED (LOW | HIGH) | NOCOMPRESS)
     ;
 
-tempfileSpecification
-    : TEMPFILE
-      (COMMA_? datafileTempfileSpec)
+datafileTempfileClauses
+    : ADD (DATAFILE | TEMPFILE) (fileSpecification (COMMA_ 
fileSpecification)*)?
+    | DROP (DATAFILE | TEMPFILE) (fileName | fileNumber)
+    | SHRINK TEMPFILE (fileName | fileNumber) (KEEP sizeClause)?
+    | RENAME DATAFILE fileName (COMMA_ fileName)* TO fileName (COMMA_ 
fileName)*
+    | (DATAFILE | TEMPFILE) (ONLINE | OFFLINE)
     ;
 
 tablespaceLoggingClauses
-    : loggingClause
-    | NO? FORCE LOGGING
+    : loggingClause | NO? FORCE LOGGING
     ;
 
 tablespaceStateClauses
-    : ONLINE
-    | OFFLINE (NORMAL | TEMPORARY | IMMEDIATE)?
-    | READ (ONLY | WRITE)
-    | PERMANENT
-    | TEMPORARY
+    : ONLINE | OFFLINE (NORMAL | TEMPORARY | IMMEDIATE)? | READ (ONLY | WRITE) 
| (PERMANENT | TEMPORARY)
     ;
 
 tablespaceFileNameConvert
-    : FILE_NAME_CONVERT EQ_ LP_ CHAR_STRING COMMA_ CHAR_STRING (COMMA_ 
CHAR_STRING COMMA_ CHAR_STRING)* RP_ KEEP?
+    : FILE_NAME_CONVERT EQ_ LP_ filenamePattern COMMA_ 
replacementFilenamePattern (COMMA_ filenamePattern COMMA_ 
replacementFilenamePattern)* RP_ KEEP?
     ;
 
 alterTablespaceEncryption
-    : ENCRYPTION ( OFFLINE (tablespaceEncryptionSpec? ENCRYPT | DECRYPT)
-                 | ONLINE (tablespaceEncryptionSpec? (ENCRYPT | REKEY) | 
DECRYPT) tablespaceFileNameConvert?
-                 | FINISH (ENCRYPT | REKEY | DECRYPT) 
tablespaceFileNameConvert?
-                 )
+    : ENCRYPTION(OFFLINE (tablespaceEncryptionSpec? ENCRYPT | DECRYPT) 
+    | ONLINE (tablespaceEncryptionSpec? (ENCRYPT | REKEY) | DECRYPT) 
tablespaceFileNameConvert?
+    | FINISH (ENCRYPT | REKEY | DECRYPT) tablespaceFileNameConvert?)
     ;
 
 dropFunction
diff --git a/test/it/parser/src/main/resources/case/ddl/alter-table.xml 
b/test/it/parser/src/main/resources/case/ddl/alter-table.xml
index c230ad9aec0..1fd9f5bdae0 100644
--- a/test/it/parser/src/main/resources/case/ddl/alter-table.xml
+++ b/test/it/parser/src/main/resources/case/ddl/alter-table.xml
@@ -1727,6 +1727,10 @@
         <table name="t1" start-index="12" stop-index="13" />
     </alter-table>
     
+    <alter-table sql-case-id="alter_table_modify_lob_storage_maxsize_cache">
+        <table name="xml_lob_tab" start-index="12" stop-index="22" />
+    </alter-table>
+    
     <alter-table sql-case-id="alter_table_move_compress_for_oltp">
         <table name="table_name" start-index="12" stop-index="21" />
     </alter-table>
diff --git a/test/it/parser/src/main/resources/case/ddl/alter-tablespace.xml 
b/test/it/parser/src/main/resources/case/ddl/alter-tablespace.xml
index 0f821a3fd69..7c9dccc0ec1 100644
--- a/test/it/parser/src/main/resources/case/ddl/alter-tablespace.xml
+++ b/test/it/parser/src/main/resources/case/ddl/alter-tablespace.xml
@@ -137,4 +137,16 @@
     <alter-tablespace sql-case-id="alter_tablespace_autoextend_on_next_g">
         <tablespace start-index="17" stop-index="22" name="bigtbs" />
     </alter-tablespace>
+    
+    <alter-tablespace sql-case-id="alter_tablespace_add_datafile_size_m">
+        <tablespace start-index="17" stop-index="22" name="lmtbsb" />
+    </alter-tablespace>
+    
+    <alter-tablespace sql-case-id="alter_tablespace_nologging">
+        <tablespace start-index="17" stop-index="22" name="tbs_03" />
+    </alter-tablespace>
+    
+    <alter-tablespace sql-case-id="alter_tablespace_add_tempfile_size_m_reuse">
+        <tablespace start-index="17" stop-index="22" name="lmtemp" />
+    </alter-tablespace>
 </sql-parser-test-cases>
diff --git 
a/test/it/parser/src/main/resources/sql/supported/ddl/alter-table.xml 
b/test/it/parser/src/main/resources/sql/supported/ddl/alter-table.xml
index 035f6877b5e..9e9e5cdd870 100644
--- a/test/it/parser/src/main/resources/sql/supported/ddl/alter-table.xml
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/alter-table.xml
@@ -235,6 +235,7 @@
     <sql-case id="alter_table_modify_lob_deduplicate" value="ALTER TABLE t1 
MODIFY LOB(a) (DEDUPLICATE)" db-types="Oracle" />
     <sql-case id="alter_table_modify_lob_nocompress" value="ALTER TABLE t1 
MODIFY LOB(a) (NOCOMPRESS)" db-types="Oracle" />
     <sql-case id="alter_table_modify_lob_encrypt_using" value="ALTER TABLE t1 
MODIFY LOB(a) (ENCRYPT USING '3DES168')" db-types="Oracle" />
+    <sql-case id="alter_table_modify_lob_storage_maxsize_cache" value="ALTER 
TABLE xml_lob_tab MODIFY LOB (XMLDATA) (STORAGE (MAXSIZE 2G) CACHE)" 
db-types="Oracle" />
     <sql-case id="alter_table_move_compress_for_oltp" value="ALTER TABLE 
table_name MOVE COMPRESS FOR OLTP" db-types="Oracle" />
     <sql-case id="alter_table_modify_encrypt_identified_by_password" 
value="ALTER TABLE t1 MODIFY ( a CLOB ENCRYPT IDENTIFIED BY foo)" 
db-types="Oracle" />
     <sql-case id="alter_table_move_nocompress_parallel" value="ALTER TABLE 
table_name MOVE NOCOMPRESS PARALLEL" db-types="Oracle" />
diff --git 
a/test/it/parser/src/main/resources/sql/supported/ddl/alter-tablespace.xml 
b/test/it/parser/src/main/resources/sql/supported/ddl/alter-tablespace.xml
index fc7bd09906d..395fefe68c7 100644
--- a/test/it/parser/src/main/resources/sql/supported/ddl/alter-tablespace.xml
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/alter-tablespace.xml
@@ -59,4 +59,7 @@
                  TO '/u02/oracle/rbdb1/users01.dbf',
                     '/u02/oracle/rbdb1/users02.dbf'" db-types="Oracle" />
     <sql-case id="alter_tablespace_autoextend_on_next_g" value="ALTER 
TABLESPACE bigtbs AUTOEXTEND ON NEXT 20G" db-types="Oracle" />
+    <sql-case id="alter_tablespace_add_datafile_size_m" value="ALTER 
TABLESPACE lmtbsb ADD DATAFILE '/u02/oracle/data/lmtbsb02.dbf' SIZE 1M" 
db-types="Oracle" />
+    <sql-case id="alter_tablespace_nologging" value="ALTER TABLESPACE tbs_03 
NOLOGGING" db-types="Oracle" />
+    <sql-case id="alter_tablespace_add_tempfile_size_m_reuse" value="ALTER 
TABLESPACE lmtemp ADD TEMPFILE '/u02/oracle/data/lmtemp02.dbf' SIZE 18M REUSE" 
db-types="Oracle" />
 </sql-cases>

Reply via email to