Bug #63999 SOURCE and \. commands not supported
Submitted: 11 Jan 2012 17:28 Modified: 12 Jan 2012 6:50
Reporter: Kevin Abel Email Updates:
Status: Verified Impact on me:
Category:MySQL Workbench: SQL Editor Severity:S4 (Feature request)
Version:5.2.37 OS:Any
Assigned to:
Triage: Needs Triage: D5 (Feature request)

[11 Jan 2012 17:28] Kevin Abel
According to MySQL documentation you can use the "SOURCE" or "\." commands (from the mysql client) to executre statements from files. However, these commands are not supported in MySQL workbench and will return a syntax error.

Technically those commands are not SQL syntax, but they are handy when writing scripts that call other scripts.

How to repeat:
Have a file saved at ~/some_other_script.sql with the following:
SELECT * FROM my_other_table;

In the SQL Editor enter the following:
SELECT * FROM my_table;
SOURCE ~/some_other_script.sql

The first line in the Editor will succeed, but the second line will fail with:
"Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SOURCE …"

Suggested fix:
Please implement the mysql client feature that allows the use of the "SOURCE" and/or "\." commands.
[12 Jan 2012 6:50] Valerii Kravchuk
Thank you for the feature request.
[3 Sep 2012 15:32] Michael McLaughlin
After posting to my blog, an interesting question pointed out that there's no business reason to add this feature in the request. Here's my take on why there's a business need:

While you can run any number of scripts individually and successfully, you can’t create a script to run a series of scripts in a specific order. That leaves us with two options: write down the order during integration testing and hand the list to the DBA to run in stage or production; or consolidate the scripts into one master script.

The former places execution sequence at risk, and the latter diminishes identification of ownership when an error occurs. Once an organization gets beyond a single developer, multiple scripts evolve at every major and point release. 

It’s my take that you should be able to wrap the execution sequence of scripts with a master script (one to bind them together and abstract their relationship sequence). That’s behavior currently doesn’t exist and from my perspective should exist.