diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-11-21 10:51:10 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-11-21 10:51:10 +0200 |
commit | 7933367a27b572d5cd02972e00dfe3303d59d5f4 (patch) | |
tree | f3f912e93c4ca89cb75490dab59c451081c8841d /mysql-test/suite/compat | |
parent | 8283948846740a22f96bbe7bccf250708406d5d9 (diff) | |
parent | bebe193979405b28b15af008621248ed117e54a4 (diff) | |
download | mariadb-git-7933367a27b572d5cd02972e00dfe3303d59d5f4.tar.gz |
Merge 10.10 into 10.11
Diffstat (limited to 'mysql-test/suite/compat')
-rw-r--r-- | mysql-test/suite/compat/oracle/r/sp-package.result | 75 | ||||
-rw-r--r-- | mysql-test/suite/compat/oracle/t/sp-package.test | 72 |
2 files changed, 147 insertions, 0 deletions
diff --git a/mysql-test/suite/compat/oracle/r/sp-package.result b/mysql-test/suite/compat/oracle/r/sp-package.result index daa244a3c5a..ef0acea5da1 100644 --- a/mysql-test/suite/compat/oracle/r/sp-package.result +++ b/mysql-test/suite/compat/oracle/r/sp-package.result @@ -3268,3 +3268,78 @@ a This is db1.pkg1.p1 DROP DATABASE db1; DROP DATABASE db2; +# +# MDEV-29370 Functions in packages are slow and seems to ignore deterministic +# +SET SQL_MODE=ORACLE; +CREATE TABLE t1 (c1 CHAR(1)); +CREATE FUNCTION f1_deterministic() +RETURN CHAR(1) +DETERMINISTIC +IS +BEGIN +RETURN 'X'; +END; +// +CREATE FUNCTION f2_not_deterministic() +RETURN CHAR(1) +IS +BEGIN +RETURN 'X'; +END; +// +CREATE PACKAGE pkg1 +IS +PROCEDURE t1_populate(numrows INTEGER); +FUNCTION f3_deterministic() RETURN CHAR(1) DETERMINISTIC; +FUNCTION f4_not_deterministic() RETURN CHAR(1); +END; +// +CREATE PACKAGE BODY pkg1 +IS +PROCEDURE t1_populate(numrounds INTEGER) +IS +i INTEGER; +BEGIN +INSERT INTO t1 VALUES('Y'); +FOR i IN 1..numrounds LOOP +INSERT INTO t1 SELECT * FROM t1; +END LOOP; +END; +FUNCTION f3_deterministic() RETURN CHAR(1) DETERMINISTIC COMMENT 'xxx' + IS +BEGIN +RETURN 'X'; +END; +FUNCTION f4_not_deterministic() RETURN CHAR(1) +IS +BEGIN +RETURN 'X'; +END; +END; +// +CALL pkg1.t1_populate(3); +EXPLAIN EXTENDED SELECT 'Deterministic function', COUNT(*) FROM t1 WHERE c1 = f1_deterministic(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 8 100.00 Using where +Warnings: +Note 1003 select 'Deterministic function' AS "Deterministic function",count(0) AS "COUNT(*)" from "test"."t1" where "test"."t1"."c1" = <cache>("f1_deterministic"()) +EXPLAIN EXTENDED SELECT 'Non-deterministic function', COUNT(*) FROM t1 WHERE c1 = f2_not_deterministic(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 8 100.00 Using where +Warnings: +Note 1003 select 'Non-deterministic function' AS "Non-deterministic function",count(0) AS "COUNT(*)" from "test"."t1" where "test"."t1"."c1" = "f2_not_deterministic"() +EXPLAIN EXTENDED SELECT 'Deterministic package function', COUNT(*) FROM t1 WHERE c1 = pkg1.f3_deterministic(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 8 100.00 Using where +Warnings: +Note 1003 select 'Deterministic package function' AS "Deterministic package function",count(0) AS "COUNT(*)" from "test"."t1" where "test"."t1"."c1" = <cache>("test"."pkg1"."f3_deterministic"()) +EXPLAIN EXTENDED SELECT 'Non-deterministic package function', COUNT(*) FROM t1 WHERE c1 = pkg1.f4_not_deterministic(); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 8 100.00 Using where +Warnings: +Note 1003 select 'Non-deterministic package function' AS "Non-deterministic package function",count(0) AS "COUNT(*)" from "test"."t1" where "test"."t1"."c1" = "test"."pkg1"."f4_not_deterministic"() +DROP TABLE t1; +DROP FUNCTION f1_deterministic; +DROP FUNCTION f2_not_deterministic; +DROP PACKAGE pkg1; diff --git a/mysql-test/suite/compat/oracle/t/sp-package.test b/mysql-test/suite/compat/oracle/t/sp-package.test index 615ce51e195..0092c869d50 100644 --- a/mysql-test/suite/compat/oracle/t/sp-package.test +++ b/mysql-test/suite/compat/oracle/t/sp-package.test @@ -3016,3 +3016,75 @@ CALL db2.pkg1.p2_db1_pkg1_p1; DROP DATABASE db1; DROP DATABASE db2; + + +--echo # +--echo # MDEV-29370 Functions in packages are slow and seems to ignore deterministic +--echo # + +SET SQL_MODE=ORACLE; + +CREATE TABLE t1 (c1 CHAR(1)); + +DELIMITER //; +CREATE FUNCTION f1_deterministic() +RETURN CHAR(1) +DETERMINISTIC +IS +BEGIN + RETURN 'X'; +END; +// + +CREATE FUNCTION f2_not_deterministic() +RETURN CHAR(1) +IS +BEGIN + RETURN 'X'; +END; +// + +CREATE PACKAGE pkg1 +IS + PROCEDURE t1_populate(numrows INTEGER); + FUNCTION f3_deterministic() RETURN CHAR(1) DETERMINISTIC; + FUNCTION f4_not_deterministic() RETURN CHAR(1); +END; +// + +CREATE PACKAGE BODY pkg1 +IS + PROCEDURE t1_populate(numrounds INTEGER) + IS + i INTEGER; + BEGIN + INSERT INTO t1 VALUES('Y'); + FOR i IN 1..numrounds LOOP + INSERT INTO t1 SELECT * FROM t1; + END LOOP; + END; + FUNCTION f3_deterministic() RETURN CHAR(1) DETERMINISTIC COMMENT 'xxx' + IS + BEGIN + RETURN 'X'; + END; + FUNCTION f4_not_deterministic() RETURN CHAR(1) + IS + BEGIN + RETURN 'X'; + END; +END; +// +DELIMITER ;// + +CALL pkg1.t1_populate(3); + +EXPLAIN EXTENDED SELECT 'Deterministic function', COUNT(*) FROM t1 WHERE c1 = f1_deterministic(); +EXPLAIN EXTENDED SELECT 'Non-deterministic function', COUNT(*) FROM t1 WHERE c1 = f2_not_deterministic(); +EXPLAIN EXTENDED SELECT 'Deterministic package function', COUNT(*) FROM t1 WHERE c1 = pkg1.f3_deterministic(); +EXPLAIN EXTENDED SELECT 'Non-deterministic package function', COUNT(*) FROM t1 WHERE c1 = pkg1.f4_not_deterministic(); + +DROP TABLE t1; +DROP FUNCTION f1_deterministic; +DROP FUNCTION f2_not_deterministic; +DROP PACKAGE pkg1; |