Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve alter tablespace syntax rules #28847

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,10 @@ tablespaceName
: identifier
;

newTablespaceName
: identifier
;

subprogramName
: identifier
;
Expand Down Expand Up @@ -1727,6 +1731,10 @@ filenamePattern
: STRING_
;

replacementFilenamePattern
: STRING_
;

connectString
: STRING_
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3922,7 +3922,7 @@ segmentManagementClause
;

tablespaceGroupClause
: TABLESPACE GROUP tablespaceGroupName
: TABLESPACE GROUP (tablespaceGroupName | SQ_ SQ_)
;

temporaryTablespaceClause
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/it/parser/src/main/resources/case/ddl/alter-table.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
12 changes: 12 additions & 0 deletions test/it/parser/src/main/resources/case/ddl/alter-tablespace.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>