Bug #82241 syntax error message while using source command in mysqlsh
Submitted: 15 Jul 2016 7:41 Modified: 21 Jul 2016 7:24
Reporter: Shahriyar Rzayev (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Document Store: MySQL Shell Severity:S2 (Serious)
Version:1.0.4 OS:Any
Assigned to: CPU Architecture:Any

[15 Jul 2016 7:41] Shahriyar Rzayev
Description:
Easy way to reproduce:

[root@pxc_5_7 world_x-db]# mysqlsh -uproxysql -pproxysql -h 127.0.0.1 --sql 
mysqlx: [Warning] Using a password on the command line interface can be insecure.
Creating a Node Session to proxysql@127.0.0.1:33060
No default schema selected.

Welcome to MySQL Shell 1.0.4 Development Preview

Currently in SQL mode. Use \js or \py to switch the shell to a scripting language.
mysql-sql> source world_x.sql;
ERROR: 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 world_x.sql' at line 1

From mysql client it works.

How to repeat:
See description.

Suggested fix:
No idea.
[20 Jul 2016 9:11] Umesh Shastry
Hi Shahriyar Rzayev,

Thank you for the report.
I think you need to prefix '\' with the source command.
See https://dev.mysql.com/doc/refman/5.7/en/mysql-shell-commands.html

==

root@ubuntu1604lts:/home/ushastry/Downloads# dpkg -i mysql-shell_1.0.4-1ubuntu16.04_amd64.deb 
Selecting previously unselected package mysql-shell:amd64.
(Reading database ... 307544 files and directories currently installed.)
Preparing to unpack mysql-shell_1.0.4-1ubuntu16.04_amd64.deb ...
Unpacking mysql-shell:amd64 (1.0.4-1ubuntu16.04) ...
Setting up mysql-shell:amd64 (1.0.4-1ubuntu16.04) ...
Processing triggers for man-db (2.7.5-1) ...
root@ubuntu1604lts:/home/ushastry/Downloads# 

root@ubuntu1604lts:/home/ushastry/Downloads# mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.7.13 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> INSTALL PLUGIN mysqlx SONAME 'mysqlx.so';
Query OK, 0 rows affected (0.14 sec)

mysql> show plugins;
+----------------------------+----------+--------------------+----------------+---------+
| Name                       | Status   | Type               | Library        | License |
+----------------------------+----------+--------------------+----------------+---------+
.

| mysqlx                     | ACTIVE   | DAEMON             | mysqlx.so      | GPL     |
+----------------------------+----------+--------------------+----------------+---------+
46 rows in set (0.00 sec)

mysql> 

root@ubuntu1604lts:/home/ushastry/Downloads# mysqlsh --uri root@localhost:33060 --sql
Creating a Node Session to root@localhost:33060
Enter password:
No default schema selected.

Welcome to MySQL Shell 1.0.4 Development Preview

Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type '\help', '\h' or '\?' for help.

Currently in SQL mode. Use \js or \py to switch the shell to a scripting language.
mysql-sql> source world.sql;
ERROR: 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 world.sql' at line 1

mysql-sql> \h
===== Global Commands =====
\help       (\?,\h)    Print this help.
\sql                   Switch to SQL processing mode.
\js                    Switch to JavaScript processing mode.
\py                    Switch to Python processing mode.
\source     (\.)       Execute a script file. Takes a file name as an argument.
\                      Start multi-line input when in SQL mode.
\quit       (\q,\exit) Quit MySQL Shell.
\connect    (\c)       Connect to a server.
\warnings   (\W)       Show warnings after every statement.
\nowarnings (\w)       Don't show warnings after every statement.
\status     (\s)       Print information about the current global connection.
\use        (\u)       Set the current schema for the global session.
\saveconn   (\savec)   Store a session configuration.
\rmconn     (\rmc)     Remove the stored session configuration.
\lsconn     (\lsc)     List stored session configurations.

===== SQL Mode Commands =====

For help on a specific command use the command as \? <command>
mysql-sql> 

===== SQL Mode Commands =====

For help on a specific command use the command as \? <command>
mysql-sql> \source world.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

.

Thanks,
Umesh
[21 Jul 2016 7:15] Shahriyar Rzayev
Yes you are right. The command should be:

mysql-sql> \source wordl.sql
Failed to open file 'wordl.sql', error: 2

Please mark as not a bug :)
[21 Jul 2016 7:24] Umesh Shastry
Thank you for confirming!