rdagumampan / yuniql

Free and open source schema versioning and database migration made natively with .NET/6. NEW THIS MAY 2022! v1.3.15 released!
https://yuniql.io
Apache License 2.0
417 stars 63 forks source link

Yuniql fails on a MariaDB procedure definition that contains a nested BEGIN END block #308

Open svegasoft opened 11 months ago

svegasoft commented 11 months ago

The error message:

... has failed while attempting to execute script file filename.sql due to error "(0x80004005) Error 0: Fatal error encountered during command execution."

SQL script:

drop procedure if exists test;

CREATE PROCEDURE test()
BEGIN

   DECLARE EXIT HANDLER FOR SQLEXCEPTION
   BEGIN
      SET @error = 'In SQLEXCEPTION handler';
   END;
END

I turned on general_log in MariaDB and examining the log could see that this script wasn't sent to the server indicating that the failure occured in yuniql.

sselvia commented 11 months ago

MariaDB should work the same as MySQL - Yuniql does not support the delimiter value that you set in MySQL Workbench. We found placing the entire procedure or trigger block on one line, yunql worked. You have an extra begin end block that we don't have.

CREATE PROCEDURE test() BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN SET @error = 'In SQLEXCEPTION handler'; END; END;

svegasoft commented 11 months ago

This is not setting a delimiter, DECLARE EXIT HANDLER FOR SQLEXCEPTION is a compound statement supported by MySql with its own BEGIN END and it can be nested inside a stored procedure. Here is a MySql doc reference: https://dev.mysql.com/doc/refman/8.0/en/declare-handler.html