FlyingZC opened a new issue, #27645:
URL: https://github.com/apache/shardingsphere/issues/27645

   # Background
   Hi community,
   
   ShardingSphere parser engine helps users parse a SQL to get the AST 
(Abstract Syntax Tree) and visit this tree to get SQLStatement (Java Object). 
Currently, we are planning to enhance the support for openGauss SQL parsing in 
ShardingSphere.
   
   More details:
   
https://shardingsphere.apache.org/document/current/en/reference/sharding/parse/
   
   # Task
   This issue is to support more openGauss sql parse, as follows:
   ```sql
   CREATE OR REPLACE PROCEDURE proc_loop(i in integer, count out integer) 
   AS 
       BEGIN 
           count:=0; 
           LOOP 
           IF count > i THEN 
               raise info 'count is %. ', count;  
               EXIT; 
           ELSE 
               count:=count+1; 
           END IF; 
           END LOOP; 
       END;
   /
   
   CALL proc_loop(10,5);
   ```
   
   ```sql
   CREATE TABLE integertable(c1 integer) ; 
   CREATE OR REPLACE PROCEDURE proc_while_loop(maxval in integer) 
   AS 
       DECLARE 
       i int :=1;  
       BEGIN 
           WHILE i < maxval LOOP 
               INSERT INTO integertable VALUES(i); 
               i:=i+1; 
           END LOOP; 
       END; 
   /
   
   --调用函数
   CALL proc_while_loop(10);
   
   --删除存储过程和表
   DROP PROCEDURE proc_while_loop;
   DROP TABLE integertable;
   ```
   
   ```sql
   CREATE TABLE hdfs_t1 (
     title NUMBER(6),
     did VARCHAR2(20),
     data_period VARCHAR2(25),
     kind VARCHAR2(25),
     interval VARCHAR2(20),
     time DATE,
     isModified VARCHAR2(10)
   );
   
   INSERT INTO hdfs_t1 VALUES( 8, 'Donald', 'OConnell', 'DOCONNEL', 
'650.507.9833', to_date('21-06-1999', 'dd-mm-yyyy'), 'SH_CLERK' );
   
   CREATE OR REPLACE PROCEDURE proc_forall()
   AS 
   BEGIN 
       FORALL i IN 100..120 
           update hdfs_t1 set title = title + 100*i;
   END; 
   /
   
   --调用函数
   CALL proc_forall();
   
   --查询存储过程调用结果
   SELECT * FROM hdfs_t1 WHERE title BETWEEN 100 AND 120;
   
   --删除存储过程和表
   DROP PROCEDURE proc_forall;
   DROP TABLE hdfs_t1;
   ```
   
   ```sql
   CREATE OR REPLACE PROCEDURE label_loop(i in integer, count out integer)
   AS
       BEGIN
           count:=0;
           label:
           LOOP
           IF count > i THEN
               raise info 'count is %. ', count;
               LEAVE;
           ELSE
               count:=count+1;
           END IF;
           END LOOP label;
       END;
   /
   
   CALL proc_loop(10,5);
   ```
   
   ```sql
   create or replace procedure while_test()
   as 
   declare _i integer = 0;
   BEGIN
   the_while:
     while _i < 10 do
       _i := _i + 1;
       continue the_while when _i % 2 = 0;
       raise notice '%', _i;
     end while the_while;
   end; 
   /
   
   select while_test();
   ```
   
   # Process
   1. First confirm that this is a correct openGauss sql syntax, if not please 
leave a message under the issue and ignore it;
   2. Compare SQL definitions in Official SQL Doc and ShardingSphere SQL Doc;
   3. If there is any difference in ShardingSphere SQL Doc, please correct them 
by referring to the Official SQL Doc;
   4. Run mvn install the current_file_module;
   5. Check whether there are any exceptions. If indeed, please fix them. 
(Especially xxxVisitor.class);
   6. Add new corresponding SQL case in SQL Cases and expected parsed result in 
Expected Statement XML;
   7. Run SQLParserParameterizedTest to make sure no exceptions.
   
   # Relevant Skills
   1. Master JAVA language
   2. Have a basic understanding of Antlr `g4` file
   3. Be familiar with openGauss SQLs


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to