Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


Quelle  ps_in_func-commit.result   Sprache: Lisp

 

#
# MDEV-39518 Allow prepared statements in stored functions in assignment right hand
#
#
# PREPARE/EXECUTE/DEALLOCATE
#
CREATE FUNCTION f1(query TEXT) RETURNS INT
BEGIN
DECLARE nrows INT;
PREPARE stmt FROM query;
EXECUTE stmt;
SET nrows= ROW_COUNT();
DEALLOCATE PREPARE stmt;
RETURN nrows;
END;
$$
CREATE PROCEDURE p1(query TEXT)
BEGIN
DECLARE nrows INT;
SET nrows= f1(query);
SELECT nrows;
SELECT * FROM t1;
END;
$$
CALL p1('CREATE TABLE t1 (a INT)');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
CREATE TABLE t1 (a INT);
CALL p1('ALTER TABLE t1 MODIFY a BIGINT');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
CALL p1('DROP TABLE t1');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
CALL p1('START TRANSACTION');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
CALL p1('COMMIT');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
CALL p1('ROLLBACK');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
CALL p1('LOCK TABLES t1 READ');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
CALL p1('LOCK TABLES t1 WRITE');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
DROP TABLE t1;
DROP PROCEDURE p1;
DROP FUNCTION f1;
#
# Same as above but with EXECUTE IMMEDIATE
# Statements causing implicit or explicit commit are not allowed, e.g:
# - DDL statements
# - COMMIT
# Even in assignment context
#
CREATE FUNCTION f1(query TEXT) RETURNS INT
BEGIN
DECLARE nrows INT;
EXECUTE IMMEDIATE query;
SET nrows= ROW_COUNT();
RETURN nrows;
END;
$$
CREATE PROCEDURE p1(query TEXT)
BEGIN
DECLARE nrows INT;
SET nrows= f1(query);
SELECT nrows;
SELECT * FROM t1;
END;
$$
CALL p1('CREATE TABLE t1 (a INT)');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
CREATE TABLE t1 (a INT);
CALL p1('ALTER TABLE t1 MODIFY a BIGINT');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
CALL p1('DROP TABLE t1');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
CALL p1('START TRANSACTION');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
CALL p1('COMMIT');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
CALL p1('ROLLBACK');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
CALL p1('LOCK TABLES t1 READ');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
CALL p1('LOCK TABLES t1 WRITE');
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
DROP TABLE t1;
DROP PROCEDURE p1;
DROP FUNCTION f1;
#
# MDEV-40225 Assertion `!thd->in_sub_stmt && !(thd->state_flags & Open_tables_state::BACKUPS_AVAIL)' failed in int Locked_tables_list::unlock_locked_tables(THD *)
#
CREATE TABLE t1(a INT);
CREATE FUNCTION f() RETURNS INT
BEGIN
EXECUTE IMMEDIATE '
LOCK TABLES t1 WRITE';
RETURN 1;
END;
$$
CREATE PROCEDURE p()
BEGIN
DECLARE v INT DEFAULT f();
END;
$$
CALL p();
ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger
DROP PROCEDURE p;
DROP FUNCTION f;
DROP TABLE t1;
#
# MDEV-40890 ROLLBACK TO SAVEPOINT crashes the server
#
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (10);
CREATE FUNCTION f1() RETURNS INT
BEGIN
SAVEPOINT s;
UPDATE t1 SET a=11;
ROLLBACK TO SAVEPOINT s;
RETURN 1;
END;
$$
CREATE PROCEDURE p1()
BEGIN
DECLARE a INT DEFAULT f1();
END;
$$
START TRANSACTION;
CALL p1;
COMMIT;
SELECT * FROM t1;
a
10
DROP PROCEDURE p1;
DROP FUNCTION f1;
DROP TABLE t1;
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (10);
CREATE FUNCTION f1() RETURNS INT
BEGIN
EXECUTE IMMEDIATE '
SAVEPOINT s';
UPDATE t1 SET a=11;
EXECUTE IMMEDIATE '
ROLLBACK TO SAVEPOINT s';
RETURN 1;
END;
$$
CREATE PROCEDURE p1()
BEGIN
DECLARE a INT DEFAULT f1();
END;
$$
START TRANSACTION;
CALL p1;
COMMIT;
SELECT * FROM t1;
a
10
DROP PROCEDURE p1;
DROP FUNCTION f1;
DROP TABLE t1;
# End of 13.1 tests

Messung
CHZG
1009710098

¤ Dauer der Verarbeitung: 0.5 Sekunden  ¤

*© Formatika GbR, Deutschland







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,187,974
#Domains=976,188