v2.3修复

This commit is contained in:
2026-05-29 08:32:28 +08:00
parent 61bdaa6d70
commit 122ffb4e0d
2 changed files with 75 additions and 32 deletions

View File

@@ -297,13 +297,13 @@ async def _execute_sql_content(cursor, sql_content: str):
current_block = []
continue
elif stripped.upper() == 'DELIMITER ;':
# 执行累积的存储过程
# 执行缓冲区中剩余的存储过程
if current_block:
proc_sql = '\n'.join(current_block).strip()
if proc_sql:
# 移除存储过程结尾的 $$ 定界符(发送给 MySQL 服务器时不需要)
proc_sql = re.sub(r'\$\$\s*$', '', proc_sql)
await cursor.execute(proc_sql)
if proc_sql:
await cursor.execute(proc_sql)
in_procedure = False
current_block = []
continue
@@ -313,6 +313,15 @@ async def _execute_sql_content(cursor, sql_content: str):
if in_procedure:
current_block.append(line)
# 遇到 $$ 结尾的行,说明一个存储过程定义结束,立即执行
if stripped.endswith('$$'):
proc_sql = '\n'.join(current_block).strip()
if proc_sql:
# 移除结尾的 $$ 定界符
proc_sql = re.sub(r'\$\$\s*$', '', proc_sql)
if proc_sql:
await cursor.execute(proc_sql)
current_block = []
else:
# 普通SQL按完整语句分割以分号结尾
if stripped: