Bug #92369 MySQL Workbench crash on SHOW (ALTER) PROCEDURE error based on Definer mismatch
Submitted: 11 Sep 2018 19:24 Modified: 11 Oct 2018 19:33
Reporter: David New Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Workbench Severity:S2 (Serious)
Version:6.3.6 OS:Linux (Ubuntu 14.04.5 LTS)
Assigned to: CPU Architecture:x86 (Build 517 CE (64 bits))
Tags: WBBugReporter

[11 Sep 2018 19:24] David New
Description:
MySQL Workbench desktop application crashes when opening (ALTER) a PROCEDURE in the sql editor schema tree, in which the procedure DEFINER is different than the default DEFINER of the local client machine. This occurs even if the procedure definer is a wildcard, ie "CREATE DEFINER `db_user`@`%` PROCEDURE...". 

My local client default DEFINER is `db_user`@`my_local_ip_address`. I can alter stored procedures that have `db_user`@`my_local_ip_address` set as the definer. If the definer is different, or a wildcard, on the server, the application crashes upon attempting to open it.

The `db_user` here has sufficient privileges granted to open the stored procedure.' Of course, `db_user` and `my_local_ip_address` here refer to actual values.

How to repeat:
Crash (steps assume you have direct access to the database for verification): 

1. Using CPanel or a command line, create a simple procedure in the database, like:

CREATE PROCEDURE `spMyProc`() BEGIN SET @a = 1; END

2. Open the new procedure in an editor and set the DEFINER to `a_valid_db_user`@`%`    -- where `a_valid_db_user` is a database user with appropriate privileges.

3. Open MySQL Workbench -> Schemas tab (SQL Editor Schema Tree), and expand the database so that Stored Procedures node appears. Expand Stored Procedures and browse to the procedure you created in step 2.

4. Right-click on the procedure in the tree and select Alter Stored Procedure... in the context menu. The application crashes and closes abruptly here. This crash is the bug.

For completeness, perform the following steps to manually prevent the crash, after performing the above steps.

5. Re-open MySQL Workbench -> Schemas tab (SQL Editor Schema Tree), and expand the database so that Stored Procedures appears.
6. Right click the Stored Procedures node and select Create Stored Procedure...
7. Create a basic procedure and save it, keeping all default values.
8. Refresh the Stored Procedures tree and find the procedure you just made. Right-click on it and selected Alter Stored Procedure...
9. Make a note of the definer that appears. Ie, CREATE DEFINER `db_user`@`host`. Close the alter procedure window without saving changes.
10. Using CPanel or command line, edit the stored procedure on the server that you created earlier in Step 2 (that caused a crash) and change the definer to match exactly what you noted in step 9.
11. In MySQL Workbench, refresh the Stored Procedures list and right-click the procedure you just changed, then select Alter Stored Procedure.
12. The procedure opens in the editor with no issue.

Suggested fix:
1. Prevent the application crash, handle gracefully. 

2. Advise whether this is a bug or not, and under what circumstances a remote user can or can't alter a stored procedure with regard to the definer. The current approach feels strict, and perhaps that is by design. I just couldn't find that answer in the documentation.
[11 Sep 2018 19:33] MySQL Verification Team
Please test with the latest version 8.0.12. Thanks.
[12 Oct 2018 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".