Bug #58601 select into outfile bug with workbench adding LIMIT, and not working w/o FROM
Submitted: 30 Nov 2010 17:34 Modified: 8 Jan 2020 21:08
Reporter: Thomas Opheys Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.1.50-community OS:Windows (xp Prof)
Assigned to: CPU Architecture:Any

[30 Nov 2010 17:34] Thomas Opheys
Description:
a) "select ... union select ... into outfile" run from the Workbench produces a syntax error because the WB by mistake adds a "LIMIT 0,x" (see first error in section 'how to repeat)

b) "select ... into outfile" does not work without a FROM although the syntax diagram in the docs would allow this

How to repeat:
/*
  ERROR 1:
  an added 'into outfile...' brings a syntax error when using the WORKBENCH because it adds a LIMIT 0,x (all the time, which is nonsense even when it doesn't lead to a syntax error)
*/
select 'X' union select distinct 'A' from INFORMATION_SCHEMA.TABLES; -- works
select 'X' union select distinct 'A' from INFORMATION_SCHEMA.TABLES into outfile 'test.csv'; -- error

select distinct 'A' from INFORMATION_SCHEMA.TABLES; -- works
select distinct 'A' from INFORMATION_SCHEMA.TABLES into outfile 'test.csv'; -- works, but WB adds a LIMIT 0,x

/*
  ERROR 2:
  select ... into outfile does not work without a FROM <table>
*/

select 'A' from dual into outfile 'test.csv'; -- works
select 'A' into outfile 'test.csv'; -- error

Suggested fix:
a) WB should not add a "LIMIT" at all if "into outfile" is used, because
   - under normal circumstances this is unexpected behaviour
   - when using a union, this even leads to a syntax error

b) allow a missing "from <table>" or document this behaviour
[30 Nov 2010 17:45] Valeriy Kravchuk
Error 1 is a bug in Workbench it seems. Error 2 is not repeatable for me:

macbook-pro:5.1 openxs$ bin/mysql -uroot test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.54-debug Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

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

mysql> select 1 into outfile '/tmp/f1.txt';
Query OK, 1 row affected (0.00 sec)

mysql> exit
Bye
macbook-pro:5.1 openxs$ cat /tmp/f1.txt
1
[1 Jan 2011 0: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".
[8 Jan 2020 21:08] Roy Lyseng
Posted by developer:
 
The second problem is not reproducible in 8.0