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

   # Background
   Hi community,
   This issue is for #26878.
   
   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 Oracle SQL parsing in 
ShardingSphere.
   
   More details:
   
https://shardingsphere.apache.org/document/current/en/reference/sharding/parse/
   
   # Task
   This issue is to support more oracle sql parse, as follows:
   ```sql
   CREATE OR REPLACE FUNCTION plsToC_concat_func ( 
      str1 IN VARCHAR2,  
      str2 IN VARCHAR2)  
   RETURN VARCHAR2 AS LANGUAGE C 
   NAME "concat" 
   LIBRARY stringlib 
   WITH CONTEXT 
   PARAMETERS ( 
   CONTEXT,  
   str1   STRING,  
   str1   INDICATOR short,  
   str2   STRING,  
   str2   INDICATOR short,  
   RETURN INDICATOR short,  
   RETURN LENGTH short,  
   RETURN STRING);
   ```
   
   ```sql
   CREATE OR REPLACE PACKAGE BODY My_Types IS
     FUNCTION Init_My_AA RETURN My_AA IS
       Ret My_AA;
     BEGIN
       Ret(-10) := '-ten';
       Ret(0) := 'zero';
       Ret(1) := 'one';
       Ret(2) := 'two';
       Ret(3) := 'three';
       Ret(4) := 'four';
       Ret(9) := 'nine';
       RETURN Ret;
     END Init_My_AA;
   END My_Types;
   ```
   
   ```sql
   CREATE OR REPLACE FUNCTION get_value
     (p_param VARCHAR2,
      p_app_id  NUMBER,
      p_role_id NUMBER
     )
     RETURN VARCHAR2
     RESULT_CACHE
   IS
     answer VARCHAR2(20);
   BEGIN
     -- Is parameter set at role level?
     BEGIN
       SELECT val INTO answer
         FROM role_level_config_params
           WHERE role_id = p_role_id
             AND name = p_param;
       RETURN answer;  -- Found
       EXCEPTION
         WHEN no_data_found THEN
           NULL;  -- Fall through to following code
     END;
     -- Is parameter set at application level?
     BEGIN
       SELECT val INTO answer
         FROM app_level_config_params
           WHERE app_id = p_app_id
             AND name = p_param;
       RETURN answer;  -- Found
       EXCEPTION
         WHEN no_data_found THEN
           NULL;  -- Fall through to following code
     END;
     -- Is parameter set at global level?
       SELECT val INTO answer
        FROM global_config_params
         WHERE name = p_param;
       RETURN answer;
   END;
   ```
   
   ```sql
   CREATE OR REPLACE FUNCTION goodbye
     RETURN BOOLEAN
   IS
   BEGIN
     RETURN(TRUE);
   END goodbye;
   ```
   
   ```sql
   CREATE OR REPLACE FUNCTION get_external_source_data
     RETURN t AUTHID DEFINER PIPELINED IS
   BEGIN
     External_Source.Init();           -- Initialize.
     <<b>> BEGIN
       LOOP                            -- Pipe rows from external source.
         PIPE ROW (External_Source.Next_Row());
       END LOOP;
     EXCEPTION
       WHEN External_Source.Done THEN  -- When no more rows are available,
         External_Source.Clean_Up();   --  clean up.
       WHEN NO_DATA_NEEDED THEN        -- When no more rows are needed,
         External_Source.Clean_Up();   --  clean up.
         RAISE NO_DATA_NEEDED;           -- Optional, equivalent to RETURN.
     END b;
   END get_external_source_data;
   ```
   
   # Process
   1. First confirm that this is a correct oracle sql syntax, if not please 
ignore;
   2. Compare SQL definitions in Oficial 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 Statment 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 Oracle 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