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 97bc2168039 add max_size to openGauss syntax (#20641)
97bc2168039 is described below
commit 97bc2168039c09728fc8c651c82ee9bddf641fef
Author: Li Hongyu <[email protected]>
AuthorDate: Thu Sep 1 18:17:45 2022 +0800
add max_size to openGauss syntax (#20641)
* try to add max_size to openGauss syntax
* add opengauss create table maxsize syntax UT
* simplify Literals.g4
Co-authored-by: bjyflihongyu <[email protected]>
---
.../src/main/antlr4/imports/opengauss/DDLStatement.g4 | 6 +++++-
.../src/main/antlr4/imports/opengauss/Keyword.g4 | 4 ++++
.../src/main/antlr4/imports/opengauss/Literals.g4 | 4 ++++
.../src/main/resources/case/ddl/create-tablespace.xml | 1 +
.../src/main/resources/sql/supported/ddl/create-tablespace.xml | 3 ++-
5 files changed, 16 insertions(+), 2 deletions(-)
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4
index ca3a90d1aad..8ff7b7a49cf 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4
@@ -323,6 +323,10 @@ onlyClause
: ONLY?
;
+fileSizeLiteral
+ : FILESIZE_LITERAL | numberLiterals
+ ;
+
asteriskClause
: ASTERISK_?
;
@@ -1586,7 +1590,7 @@ createSubscription
;
createTablespace
- : CREATE TABLESPACE name (OWNER roleSpec)? LOCATION STRING_ (WITH
reloptions)?
+ : CREATE TABLESPACE name (OWNER roleSpec)? LOCATION STRING_ (WITH
reloptions)? (MAXSIZE EQ_? fileSizeLiteral)?
;
createTextSearch
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/Keyword.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/Keyword.g4
index 61f5383ac88..f18b21fbea2 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/Keyword.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/Keyword.g4
@@ -151,6 +151,10 @@ DISTINCT
: D I S T I N C T
;
+MAXSIZE
+ : M A X S I Z E
+ ;
+
CASE
: C A S E
;
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/Literals.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/Literals.g4
index 1dc1f577bf6..0362d7db881 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/Literals.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/Literals.g4
@@ -40,6 +40,10 @@ BIT_NUM_
: '0b' ('0' | '1')+ | B SQ_ ('0' | '1')+ SQ_
;
+FILESIZE_LITERAL
+ : INT_ ('K'|'M'|'G'|'T')
+ ;
+
fragment INT_
: [0-9]+
;
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-tablespace.xml
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-tablespace.xml
index b6934d576d6..8773ce4c28d 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-tablespace.xml
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/create-tablespace.xml
@@ -17,6 +17,7 @@
-->
<sql-parser-test-cases>
+ <create-tablespace sql-case-id="create_tablespace_with_maxsize" />
<create-tablespace sql-case-id="create_tablespace_for_innodb" />
<create-tablespace sql-case-id="create_tablespace_for_myisam" />
<create-tablespace sql-case-id="create_undo_tablespace_for_innodb" />
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-tablespace.xml
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-tablespace.xml
index e4557fe7cee..330cb6e7b46 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-tablespace.xml
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/create-tablespace.xml
@@ -17,8 +17,9 @@
-->
<sql-cases>
+ <sql-case id="create_tablespace_with_maxsize" value="CREATE TABLESPACE ts1
LOCATION '/openGauss/tbspc_test' maxsize=19M" db-types="openGauss" />
<sql-case id="create_tablespace_for_innodb" value="CREATE TABLESPACE `ts1`
ADD DATAFILE '/my/tablespace/directory/ts1.ibd' Engine=InnoDB;"
db-types="MySQL" />
- <sql-case id="create_tablespace_for_myisam" value="CREATE TABLESPACE
ndb_ts1 ADD DATAFILE 'ndb_ts1.dat' USE LOGFILE GROUP ndb_lg1 ENGINE=MyISAM"
db-types="MySQL" />
+ <sql-case id="create_tablespace_for_myisam" value="CREATE TABLESPACE
ndb_ts1 ADD DATAFILE 'ndb_ts1.dat' USE LOGFILE GROUP ndb_lg1 MAX_SIZE=10M
ENGINE=MyISAM " db-types="MySQL" />
<sql-case id="create_undo_tablespace_for_innodb" value="CREATE UNDO
TABLESPACE `ts1` ADD DATAFILE '/my/tablespace/directory/ts1.ibd'
Engine=InnoDB;" db-types="MySQL" />
<sql-case id="create_undo_tablespace_for_myisam" value="CREATE UNDO
TABLESPACE ndb_ts1 ADD DATAFILE 'ndb_ts1.dat' USE LOGFILE GROUP ndb_lg1
ENGINE=MyISAM" db-types="MySQL" />
</sql-cases>