This is an automated email from the ASF dual-hosted git repository.

zouxinyi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 2f84908f5d5 [enhancement](plsql) regression for routine select and 
show create procedure (#33608)
2f84908f5d5 is described below

commit 2f84908f5d57e2cc794ade9d598350873ecff471
Author: Vallish Pai <vallish...@gmail.com>
AuthorDate: Thu Apr 18 08:46:13 2024 +0530

    [enhancement](plsql) regression for routine select and show create 
procedure (#33608)
    
    add regression for routines and show create procedure
    Issue Number: close #31297
    
    add regression for routines and show create procedure
---
 .../data/plsql_p0/test_plsql_routine.out           |  7 ++
 .../suites/plsql_p0/test_plsql_routine.groovy      | 79 ++++++++++++++++++++++
 2 files changed, 86 insertions(+)

diff --git a/regression-test/data/plsql_p0/test_plsql_routine.out 
b/regression-test/data/plsql_p0/test_plsql_routine.out
new file mode 100644
index 00000000000..316a4c1ac78
--- /dev/null
+++ b/regression-test/data/plsql_p0/test_plsql_routine.out
@@ -0,0 +1,7 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+777    4
+
+-- !select --
+2
+
diff --git a/regression-test/suites/plsql_p0/test_plsql_routine.groovy 
b/regression-test/suites/plsql_p0/test_plsql_routine.groovy
new file mode 100644
index 00000000000..2cea9a4dcca
--- /dev/null
+++ b/regression-test/suites/plsql_p0/test_plsql_routine.groovy
@@ -0,0 +1,79 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// Add PL-SQL regression test notice:
+// 1. JDBC does not support the execution of stored procedures that return 
results. You can only Into the execution
+// results into a variable or write them into a table, because when multiple 
result sets are returned, JDBC needs
+// to use the prepareCall statement to execute, otherwise the Statemnt of the 
returned result executes Finalize.
+// Send EOF Packet will report an error;
+// 2. The format of the result returned by Doris Statement is xxxx\n, xxxx\n, 
2 rows affected (0.03 sec).
+// PL-SQL uses Print to print variable values in an unformatted format, and 
JDBC cannot easily obtain them. Real results.
+suite("test_plsql_routine") {
+    def dbName = "plsql_routine"
+    sql "CREATE DATABASE IF NOT EXISTS ${dbName}"
+    sql "use ${dbName}"
+    def tableName = "plsql_tbl_4"
+    sql "DROP TABLE IF EXISTS ${tableName}"
+    sql """
+        create table ${tableName} (id int, name varchar(20)) DUPLICATE 
key(`id`) distributed by hash (`id`) buckets 4
+        properties ("replication_num"="1");
+        """
+
+    sql """
+        CREATE OR REPLACE PROCEDURE routine_insert(IN id int, IN name STRING)
+        BEGIN
+            INSERT INTO ${tableName} VALUES(id, name);
+        END;
+        """
+    sql """call routine_insert(111, "plsql111")"""
+    sql """call routine_insert(222, "plsql222")"""
+    sql """call routine_insert(333, "plsql333")"""
+    sql """call routine_insert(111, "plsql333")"""
+    qt_select "select sum(id), count(1) from ${tableName}"
+
+    sql """
+        CREATE OR REPLACE PROCEDURE routine_cursor_select(IN id_arg INT, IN 
name_arg STRING) 
+        BEGIN
+        DECLARE a INT;
+        DECLARE b, c STRING;
+
+        DECLARE cur1 CURSOR FOR select * from ${tableName} where id=id_arg 
limit 5;
+        OPEN cur1;
+        read_loop: LOOP
+            FETCH cur1 INTO a, b;
+            IF(SQLCODE != 0) THEN
+                LEAVE read_loop;
+            END IF;
+            print a, b;
+        END LOOP;
+
+        CLOSE cur1;
+
+        END;
+        """
+
+    qt_select "select count(*) from information_schema.routines where 
routine_schema=\"${dbName}\";"
+    sql """select * from information_schema.routines;"""
+    sql """call routine_cursor_select(111, "plsql111")"""
+    sql """call routine_cursor_select(111, "plsql333")"""
+    sql """SHOW CREATE PROCEDURE routine_cursor_select;"""
+    // TODO call show command before drop
+    sql """DROP PROCEDURE routine_cursor_select"""
+    sql """DROP PROC routine_insert"""
+    sql "DROP DATABASE ${dbName}"
+    // TODO call show command after drop
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to