v2.3修复
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user