Skip to content

Incorrect split results with MySQL empty exit handler #581

@jamie-burks

Description

@jamie-burks

What were you trying to accomplish?
Using sqlparse.split to split these SQL commands loaded from a text file. The first stored procedure includes a declare exit handler with an empty begin end; body which MySQL allows to ignore the referenced condition. We have tried including dummy statements inside the begin end; such as a simple select 1; but so far we have not been able to find anything that works other than removing the declare exit handler block altogether.

create procedure proc1()
begin
  declare exit handler for sqlexception begin end;
  select 1 from nowhere;
end;

create procedure proc2()
begin
  select 1;
end;

Expected Behavior

sqlparse.split should split this text into two create procedure statements.

Current Behavior

sqlparse.split is returning one statement.

Steps to Reproduce (for bugs)

Use the above script text as input to sqlparse.split.

Environment

  • Python 3.8
  • sqlparse 0.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions