`dolt_checkout()` to change branches doesn't work in stored procedures
- Dominant language
- Go
- Stars
- 24.4k
- Forks
- 873
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 108
Description
This stored procedure doesn't work correctly:
```sql
create procedure edit_on_branch()
begin
call dolt_checkout('-b', 'branch1');
insert into t(b) values (100);
call dolt_commit('-am', 'new row');
call dolt_checkout('main');
end
```
The reason it doesn't work correctly is that we analyze every statement in the stored procedure before running any of them. This means that the table `t` resolves to ``` `mydb/main`.t ```, whereas after the `dolt_checkout` procedure executes it should resolve to ``` `mydb/branch1`.t ```. Because all such statements resolve before any execute, we can't get the right branch for the insert.
The fix is to change stored procedure logic to analyze each statement individually before it is executed, rather than all at once before any execute.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.