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 ed47c66cc8c Support parsing Oracle SHOW ERRORS; sql (#30350)
ed47c66cc8c is described below

commit ed47c66cc8c1d650209d033f95bd1634ffb0a619
Author: YaoFly <[email protected]>
AuthorDate: Tue Mar 5 11:28:31 2024 +0800

    Support parsing Oracle SHOW ERRORS; sql (#30350)
    
    * Support parsing Oracle SHOW ERRORS; sql(#27167)
    
    * fix class comment for spotless check (#27167)
    
    * fix license for spotless check (#27167)
    
    * fix code style for spotless check (#27167)
    
    * Support parsing Oracle SHOW ERRORS; sql (#27167)
    
    * fix parsing sql-case-id 'pl_sql_create_procedure' (#27167)
    
    * remove uesless blank lines.(#27167)
    
    * modify java doc in OracleShowStatement class (#27167)
---
 .../src/main/antlr4/imports/oracle/BaseRule.g4     |   2 +-
 .../src/main/antlr4/imports/oracle/DALStatement.g4 |  49 ++++++++
 .../main/antlr4/imports/oracle/OracleKeyword.g4    | 132 +++++++++++++++++++++
 .../sql/parser/autogen/OracleStatement.g4          |   1 +
 .../statement/type/OracleDALStatementVisitor.java  |   7 ++
 .../statement/oracle/dal/OracleShowStatement.java} |  22 ++--
 .../asserts/statement/dal/DALStatementAssert.java  |  24 ++--
 .../it/parser/src/main/resources/case/dal/show.xml |   2 +
 .../parser/src/main/resources/case/dml/select.xml  |   8 +-
 .../src/main/resources/sql/supported/dal/show.xml  |   2 +
 10 files changed, 219 insertions(+), 30 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 24fb611dcee..64bdf9d4c59 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
@@ -334,7 +334,7 @@ unreservedWord3
     | WIDTH_BUCKET | WRAPPED | XID | XMLAGG | XMLATTRIBUTES | XMLCAST | 
XMLCDATA | XMLCOLATTVAL | XMLCOMMENT | XMLCONCAT | XMLDIFF
     | XMLEXISTS | XMLEXISTS2 | XMLFOREST | XMLINDEX_REWRITE | 
XMLINDEX_REWRITE_IN_SELECT | XMLINDEX_SEL_IDX_TBL | XMLISNODE
     | XMLISVALID | XMLNAMESPACES | XMLPARSE | XMLPATCH | XMLPI | XMLQUERY | 
XMLROOT | XMLSERIALIZE | XMLTABLE | XMLTOOBJECT
-    | XMLTRANSFORM | XMLTRANSFORMBLOB | XML_DML_RWT_STMT | XPATHTABLE | 
XS_SYS_CONTEXT | X_DYN_PRUNE | RESULT | TABLE | NUMBER | CHAR
+    | XMLTRANSFORM | XMLTRANSFORMBLOB | XML_DML_RWT_STMT | XPATHTABLE | 
XS_SYS_CONTEXT | X_DYN_PRUNE | RESULT | TABLE | NUMBER | CHAR | SQLCODE
     ;
 
 schemaName
diff --git 
a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DALStatement.g4 
b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DALStatement.g4
index 4c76572a516..2ed50927293 100644
--- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DALStatement.g4
+++ b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DALStatement.g4
@@ -30,3 +30,52 @@ dbLinkInfo
 explain
     : EXPLAIN PLAN (SET STATEMENT_ID EQ_ stringLiterals)? (INTO (schemaName 
DOT_)? tableName (AT_ dbLinkInfo)? )? FOR (insert | delete | update | select)
     ;
+
+schema
+    : identifier
+    ;
+
+parameterName
+    : identifier
+    ;
+
+originalName
+    : identifier
+    ;
+
+systemVariable
+    : identifier
+    ;
+
+showOptions
+    : systemVariable
+    | ALL
+    | CON_ID
+    | CON_NAME
+    | EDITION
+    | (BTI | BTITLE)
+    | (ERR | ERRORS) ((ANALYTIC VIEW | ATTRIBUTE DIMENSION | HIERARCHY | 
FUNCTION | PROCEDURE | PACKAGE | PACKAGE BODY | TRIGGER  | VIEW | TYPE | TYPE 
BODY | DIMENSION | JAVA CLASS) (schema DOT_)? name)?
+    | HISTORY
+    | LNO
+    | LOBPREFETCH
+    | (PARAMETER | PARAMETERS) parameterName?
+    | PDBS
+    | PNO
+    | (RECYC | RECYCLEBIN) originalName?
+    | (REL | RELEASE)
+    | (REPF | REPFOOTER)
+    | (REPH | REPHEADER)
+    | (ROWPREF | ROWPREFETCH)
+    | SGA
+    | (SPOO | SPOOL)
+    | (SPPARAMETER | SPPARAMETERS) parameterName?
+    | SQLCODE
+    | (STATEMENTC | STATEMENTCACHE)
+    | (TTI | TLE)
+    | USER
+    | XQUERY
+    ;
+
+show
+    : (SHO | SHOW) showOptions
+    ;
diff --git 
a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4 
b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
index 831374ff2cb..a6a1e8d234d 100644
--- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
+++ b/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
@@ -7811,3 +7811,135 @@ KERBEROS_PRINCIPAL_NAME
 DELEGATE
     : D E L E G A T E
     ;
+
+DEVICE
+    : D E V I C E
+    ;
+
+PARAMETER
+    :P A R A M E T E R
+    ;
+
+SHO
+    : S H O
+    ;
+
+ERR
+    : E R R
+    ;
+
+CON_ID
+    : C O N UL_ I D
+    ;
+
+CON_NAME
+    : C O N UL_ N A M E
+    ;
+
+BTI
+    : B T I
+    ;
+
+BTITLE
+    : B T I T L E
+    ;
+
+HISTORY
+    : H I S T O R Y
+    ;
+
+LNO
+    : L N O
+    ;
+
+LOBPREFETCH
+    : L O B P R E F E T C H
+    ;
+
+PDBS
+    : P D B S
+    ;
+
+PNO
+    : P N O
+    ;
+
+RECYC
+    : R E C Y C
+    ;
+
+REL
+    : R E L
+    ;
+
+RELEASE
+    : R E L E A S E
+    ;
+
+REPF
+    : R E P F
+    ;
+
+REPFOOTER
+    : R E P F O O T E R
+    ;
+
+REPH
+    : R E P H
+    ;
+
+REPHEADER
+    : R E P H E A D E R
+    ;
+
+ROWPREF
+    : R O W P R E F
+    ;
+
+ROWPREFETCH
+    : R O W P R E F E T C H
+    ;
+
+SGA
+    : S G A
+    ;
+
+SPOO
+    : S P O O
+    ;
+
+SPOOL
+    : S P O O L
+    ;
+
+SPPARAMETER
+    : S P P A R A M E T E R
+    ;
+
+SPPARAMETERS
+    : S P P A R A M E T E R S
+    ;
+
+SQLCODE
+    : S Q L C O D E
+    ;
+
+STATEMENTC
+    : S T A T E M E N T C
+    ;
+
+STATEMENTCACHE
+    : S T A T E M E N T C A C H E
+    ;
+
+TTI
+    : T T I
+    ;
+
+TLE
+    : T L E
+    ;
+
+XQUERY
+    : X Q U E R Y
+    ;
diff --git 
a/parser/sql/dialect/oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
 
b/parser/sql/dialect/oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
index 304fd60a1c8..a03adcd9d43 100644
--- 
a/parser/sql/dialect/oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
+++ 
b/parser/sql/dialect/oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
@@ -159,5 +159,6 @@ execute
     | switch
     | createProfile
     | createTrigger
+    | show
     ) SEMI_? SLASH_? EOF
     ;
diff --git 
a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDALStatementVisitor.java
 
b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDALStatementVisitor.java
index 3eb8230958f..78f684433ef 100644
--- 
a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDALStatementVisitor.java
+++ 
b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDALStatementVisitor.java
@@ -22,10 +22,12 @@ import 
org.apache.shardingsphere.sql.parser.api.visitor.statement.type.DALStatem
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AlterResourceCostContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ExecuteContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ExplainContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ShowContext;
 import 
org.apache.shardingsphere.sql.parser.oracle.visitor.statement.OracleStatementVisitor;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.dal.OracleAlterResourceCostStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.dal.OracleExplainStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.dal.OracleShowStatement;
 
 /**
  * DAL statement visitor for Oracle.
@@ -56,4 +58,9 @@ public final class OracleDALStatementVisitor extends 
OracleStatementVisitor impl
         result.getVariableNames().addAll(getVariableNames());
         return result;
     }
+    
+    @Override
+    public ASTNode visitShow(final ShowContext ctx) {
+        return new OracleShowStatement();
+    }
 }
diff --git 
a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DALStatement.g4 
b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/dal/OracleShowStatement.java
similarity index 62%
copy from 
parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DALStatement.g4
copy to 
parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/dal/OracleShowStatement.java
index 4c76572a516..bda38be9882 100644
--- a/parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DALStatement.g4
+++ 
b/parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/dal/OracleShowStatement.java
@@ -15,18 +15,14 @@
  * limitations under the License.
  */
 
-grammar DALStatement;
+package org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.dal;
 
-import BaseRule, DMLStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.OracleStatement;
 
-alterResourceCost
-    : ALTER RESOURCE COST ((CPU_PER_SESSION | CONNECT_TIME | 
LOGICAL_READS_PER_SESSION | PRIVATE_SGA) INTEGER_)+
-    ;
-
-dbLinkInfo
-    : databaseName (DOT_ domain)* (AT_ connectionQualifier)?
-    ;
-
-explain
-    : EXPLAIN PLAN (SET STATEMENT_ID EQ_ stringLiterals)? (INTO (schemaName 
DOT_)? tableName (AT_ dbLinkInfo)? )? FOR (insert | delete | update | select)
-    ;
+/**
+ * Oracle show statement.
+ */
+public final class OracleShowStatement extends AbstractSQLStatement implements 
DALStatement, OracleStatement {
+}
diff --git 
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/DALStatementAssert.java
 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/DALStatementAssert.java
index 11fec3fb81c..c356fb1c395 100644
--- 
a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/DALStatementAssert.java
+++ 
b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/DALStatementAssert.java
@@ -83,18 +83,6 @@ import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.d
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.InstallPluginStatementAssert;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.KillStatementAssert;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.LoadIndexInfoStatementAssert;
-import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLAlterResourceGroupStatementAssert;
-import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLBinlogStatementAssert;
-import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLChecksumTableStatementAssert;
-import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLCreateResourceGroupStatementAssert;
-import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLDelimiterStatementAssert;
-import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLDropResourceGroupStatementAssert;
-import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLOptimizeTableStatementAssert;
-import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLRepairTableStatementAssert;
-import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLResetPersistStatementAssert;
-import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLResetStatementAssert;
-import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLSetResourceGroupStatementAssert;
-import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLUseStatementAssert;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.ResetParameterStatementAssert;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.RestartStatementAssert;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.SetParameterStatementAssert;
@@ -125,6 +113,18 @@ import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.d
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.ShutdownStatementAssert;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.UninstallComponentStatementAssert;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.UninstallPluginStatementAssert;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLAlterResourceGroupStatementAssert;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLBinlogStatementAssert;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLChecksumTableStatementAssert;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLCreateResourceGroupStatementAssert;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLDelimiterStatementAssert;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLDropResourceGroupStatementAssert;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLOptimizeTableStatementAssert;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLRepairTableStatementAssert;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLResetPersistStatementAssert;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLResetStatementAssert;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLSetResourceGroupStatementAssert;
+import 
org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.dal.impl.mysql.MySQLUseStatementAssert;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.AlterResourceGroupStatementTestCase;
 import 
org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.BinlogStatementTestCase;
diff --git a/test/it/parser/src/main/resources/case/dal/show.xml 
b/test/it/parser/src/main/resources/case/dal/show.xml
index 9a50c696312..adce43da426 100644
--- a/test/it/parser/src/main/resources/case/dal/show.xml
+++ b/test/it/parser/src/main/resources/case/dal/show.xml
@@ -867,4 +867,6 @@
     <show sql-case-id="show_warnings_limit" />
     <show sql-case-id="show_warnings_count" />
     <show sql-case-id="show_search_path" name="search_path" />
+    <show sql-case-id="show_errors" />
+    <show sql-case-id="show_parameter_smtp_out_server" />
 </sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/case/dml/select.xml 
b/test/it/parser/src/main/resources/case/dml/select.xml
index 47701c00f9e..c8e766a76cd 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -6520,7 +6520,7 @@
             <simple-table name="employees" start-index="210" stop-index="218" 
literal-start-index="210" literal-stop-index="218" />
         </from>
     </select>
-    
+
     <select sql-case-id="select_with_trim_function_simple">
         <projections start-index="7" stop-index="57">
             <expression-projection text="TRIM( '.,! ' FROM '     #     test    
.')" start-index="7" stop-index="57" alias="Result">
@@ -6537,7 +6537,7 @@
             </expression-projection>
         </projections>
     </select>
-    
+
     <select sql-case-id="select_with_trim_function_leading">
         <projections start-index="7" stop-index="66">
             <expression-projection text="TRIM(LEADING '.,! ' FROM  '     .#    
 test    .')" start-index="7" stop-index="66" alias="Result">
@@ -6557,7 +6557,7 @@
             </expression-projection>
         </projections>
     </select>
-    
+
     <select sql-case-id="select_with_trim_function_trailing">
         <projections start-index="7" stop-index="66">
             <expression-projection text="TRIM(TRAILING '.,! ' FROM '     .#    
 test    .')" start-index="7" stop-index="66" alias="Result">
@@ -6577,7 +6577,7 @@
             </expression-projection>
         </projections>
     </select>
-    
+
     <select sql-case-id="select_with_trim_function_both">
         <projections start-index="7" stop-index="49">
             <expression-projection text="TRIM(BOTH '123' FROM '123abc123')" 
start-index="7" stop-index="49" alias="Result">
diff --git a/test/it/parser/src/main/resources/sql/supported/dal/show.xml 
b/test/it/parser/src/main/resources/sql/supported/dal/show.xml
index e052666d6ce..b995ffa0c6c 100644
--- a/test/it/parser/src/main/resources/sql/supported/dal/show.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dal/show.xml
@@ -144,4 +144,6 @@
     <sql-case id="show_warnings_limit" value="SHOW WARNINGS limit 1" 
db-types="MySQL" />
     <sql-case id="show_warnings_count" value="SHOW COUNT(*) WARNINGS" 
db-types="MySQL" />
     <sql-case id="show_search_path" value="SHOW search_path;" 
db-types="PostgreSQL,openGauss" />
+    <sql-case id="show_errors" value="SHOW ERRORS;" db-types="Oracle"/>
+    <sql-case id="show_parameter_smtp_out_server" value="SHOW PARAMETER 
SMTP_OUT_SERVER" db-types="Oracle"/>
 </sql-cases>

Reply via email to