Skip to content

[Bug]: MySQL-style CREATE PROCEDURE/FUNCTION BEGIN...END syntax is not supported #25409

Open

Description

@Ariznawlll

Environment

  • Branch: latest main
  • MO git version: 51656deb6
  • MySQL oracle: 8.0.45

Reference behavior

MySQL supports stored routines using CREATE PROCEDURE / CREATE FUNCTION with BEGIN ... END compound statements:
https://dev.mysql.com/doc/en/create-procedure.html

MySQL stored routines also support local variables, OUT parameters, handlers, and cursors:
https://dev.mysql.com/doc/en/cursors.html

Reproduce

drop database if exists mysql_compat_model15_routine;
create database mysql_compat_model15_routine;
use mysql_compat_model15_routine;

create table t_routine (
  id int primary key,
  grp int,
  v varchar(20),
  key idx_grp_v(grp, v)
);
insert into t_routine values
  (1,10,'a'),
  (2,10,'b'),
  (3,20,'c'),
  (4,null,null);

delimiter $$

create procedure p_basic(in p_min int, out p_cnt int)
begin
  select count(*) into p_cnt from t_routine where id >= p_min;
  select id, v from t_routine where id >= p_min order by id;
end$$

create function f_add(x int, y int)
returns int
deterministic
no sql
begin
  return x + y;
end$$

delimiter ;

call p_basic(2, @cnt);
select @cnt as out_count;
select f_add(2,3) as f_add_result;

MySQL result

id  v
2   b
3   c
4   NULL

out_count
3

f_add_result
5

MO result

ERROR 1064 (HY000): SQL parser error ... near "
begin
  select count(*) into p_cnt from t_routine where id >= p_min;
  select id, v from t_routine where id >= p_min order by id;
end";

ERROR 1064 (HY000): SQL parser error ... near "
deterministic
no sql
begin
  return x + y;
end";

ERROR 1122 (HY000): function p_basic doesn't exist
ERROR 20101 (HY000): internal error: the user variable cnt does not exist
ERROR 20105 (HY000): not supported: function or operator 'f_add'

Expected

MO should accept MySQL-compatible stored routine syntax for CREATE PROCEDURE and CREATE FUNCTION, including BEGIN ... END routine bodies and standard routine characteristics such as DETERMINISTIC / NO SQL.

Activity

  1. added this to the MO-202607 milestone on Jul 3, 2026
  2. added
    kind/bug
    on Jul 3, 2026
  3. added theissue type on Jul 3, 2026
  4. daviszhen commented on Sep 22, 2026

    @daviszhen
    Contributor

    补充 JeecgBoot 应用证据(关联汇总 #29220):

    JeecgBoot 上游 jeecg-boot/db/jeecgboot-mysql-5.7.sql 包含 MySQL stored procedure。MatrixOne 导入时无法解析 CREATE PROCEDURE ... BEGIN ... END 例程体,因此适配器会删除该 routine block,应用只保留表和数据后启动。

    Before:原始 schema import 在 routine 处 parser error。
    After:删除 routine 后 schema import 成功,但 stored procedure 功能丢失。需要在支持 MySQL compound routine syntax 后恢复原始 routine 并增加 JeecgBoot 回归验证。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

deferredkind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions