Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stored procedure referencing dropped column causes error during checkout or reset. #4670

Closed
druvv opened this issue Oct 31, 2022 · 1 comment · Fixed by dolthub/go-mysql-server#1373
Assignees
Labels
bug Something isn't working

Comments

@druvv
Copy link
Contributor

druvv commented Oct 31, 2022

dolt init
dolt sql -q "create table t (pk int primary key, col1 int);"
dolt sql-server

Separately:

mysql> DELIMITER //
     -> create procedure test_proc()
    -> begin
    -> select col1 from t;
    -> end //
Query OK, 0 rows affected (0.02 sec)
mysql> call dolt_commit('-Am', 'add a procedure');
+----------------------------------+
| hash                             |
+----------------------------------+
| kv143gr8danmjq38889e6p28v7dpml41 |
+----------------------------------+
1 row in set (0.01 sec)

mysql> alter table t drop col1;
Query OK, 0 rows affected (0.01 sec)

mysql> call dolt_checkout('-b', 'new', 'head^');
ERROR 1105 (HY000): column "col1" could not be found in any table in scope

Dropping the procedure resolves the issue:

mysql> drop procedure test_proc;
Query OK, 0 rows affected (0.01 sec)

mysql> call dolt_checkout('-b', 'new', 'head^');
+--------+
| status |
+--------+
|      0 |
+--------+
1 row in set (0.01 sec)
@druvv druvv added the bug Something isn't working label Oct 31, 2022
@fulghum
Copy link
Contributor

fulghum commented Nov 1, 2022

@PavelSafronov – this could be a good next issue to pick up.

The loadStoredProcedures function in stored_procedures.go has the code involved here. Currently, if we hit any error while loading stored procedures, then we give up and don't load any. Instead, we could log any errors to the server log and/or add a warning in the session's context and just load whatever stored procedures we can. Alternatively, if we can load a stored procedure, but not fully validate it, that could be a better experience. That way, customers could still see their (broken) stored procedure and when they try to call it, they'd get the appropriate error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants