Bug #13202 SELECT * INTO OUTFILE ... FROM information_schema.schemata now fails

Submitted: 14 Sep 2005 20:44 Modified: 18 Oct 2005 9:52
Reporter: Carsten Segieth Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.13 OS:Linux (Linux)
Assigned to: Sergei Glukhov CPU Architecture:Any

[14 Sep 2005 20:44] Carsten Segieth
Description:
Using a fresh compile from today lets 

SELECT *
INTO OUTFILE '../tmp/out.innodb.file'
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
  LINES TERMINATED BY 'n'
  FROM information_schema.schemata LIMIT 0, 5;

fail with

ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema'

With a compile from last weekend or earlier this was successfull.

How to repeat:
Use new compiled version (at least containing "ChangeSet@1.1954, 2005-09-14 14:54:48+04:00, petr@mysql.com", which was the newest ChS on my machine) and start

SELECT *
INTO OUTFILE '../tmp/out.innodb.file'
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
  LINES TERMINATED BY 'n'
  FROM information_schema.schemata LIMIT 0, 5;

with the default connection. You may also start the attached test file and check against the result file. They have been created using 5.0.12-beta on Win32.

Suggested fix:
Return to old behaviour.
[14 Sep 2005 20:56] MySQL Verification Team
miguel@hegel:~/dbs/5.0> bin/mysql -uroot -pmyuser
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 5.0.13-beta-valgrind-max-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SELECT *
    -> INTO OUTFILE '../home/miguel/out.innodb.file'
    ->   FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    ->   LINES TERMINATED BY 'n'
    ->   FROM information_schema.schemata LIMIT 0, 5;
ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'information_schema'
mysql> select * from information_schema.schemata;
+--------------+--------------------+----------------------------+------------------------+----------+
| CATALOG_NAME | SCHEMA_NAME        | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL_PATH |
+--------------+--------------------+----------------------------+------------------------+----------+
| NULL         | information_schema | utf8                       | utf8_general_ci        | NULL     |
| NULL         | dbg                | latin1                     | latin1_swedish_ci      | NULL     |
| NULL         | dbtest1            | latin1                     | latin1_swedish_ci      | NULL     |
| NULL         | feed_engine        | latin1                     | latin1_swedish_ci      | NULL     |
| NULL         | gh                 | latin1                     | latin1_swedish_ci      | NULL     |
| NULL         | jkl                | latin1                     | latin1_swedish_ci      | NULL     |
| NULL         | ju                 | latin1                     | latin1_swedish_ci      | NULL     |
| NULL         | kl                 | latin1                     | latin1_swedish_ci      | NULL     |
| NULL         | kr                 | latin1                     | latin1_swedish_ci      | NULL     |
| NULL         | mysql              | latin1                     | latin1_swedish_ci      | NULL     |
| NULL         | new_crash          | latin1                     | latin1_swedish_ci      | NULL     |
| NULL         | scott              | latin1                     | latin1_swedish_ci      | NULL     |
| NULL         | test               | latin1                     | latin1_swedish_ci      | NULL     |
| NULL         | ty                 | latin1                     | latin1_swedish_ci      | NULL     |
| NULL         | xxx                | latin1                     | latin1_swedish_ci      | NULL     |
+--------------+--------------------+----------------------------+------------------------+----------+
15 rows in set (0.01 sec)

mysql> show grants for 'root'@'localhost';
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost                                                                                                              |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*CBA73BBE5D9AF59311C3F4D7E8C20AA847F7B188' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> 

c:\mysql\bin>mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.12-beta-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SELECT *
    -> INTO OUTFILE 'c:/temp/out.innodb.file'
    ->   FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    ->   LINES TERMINATED BY 'n'
    ->   FROM information_schema.schemata LIMIT 0, 5;
Query OK, 3 rows affected (0.59 sec)
[16 Sep 2005 8:59] Andrey Hristov
Caused by ChangeSet 1.1943.3.1. SELECT_ACL|FILE_ACL [lex->exchange!=0] passed to check_table_access() but the function fails in:
    if (tables->schema_table && 
        (want_access & ~(SELECT_ACL | EXTRA_ACL)))
    {
      if (!no_errors)
        my_error(ER_DBACCESS_DENIED_ERROR, MYF(0),
                 thd->priv_user, thd->priv_host,
                 information_schema_name.str);
      return TRUE;
    }
[19 Sep 2005 8:48] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/30037
[4 Oct 2005 11:14] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/30677
[7 Oct 2005 9:16] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/30807
[7 Oct 2005 9:32] Sergei Glukhov
Fixed in 5.0.15-rc
[18 Oct 2005 9:52] Stefan Hinz
Added to changelog 5.0.15.
[30 Aug 2010 11:51] Guido Serra
I'm getting the same issue if selecting from a VIEW

mysql> desc v_nagios
    -> ;
+----------------+--------------+------+-----+---------------------+-------+
| Field          | Type         | Null | Key | Default             | Extra |
+----------------+--------------+------+-----+---------------------+-------+
| name1          | varchar(128) | NO   |     |                     |       |
| name2          | varchar(128) | YES  |     | NULL                |       |
| end_time       | datetime     | NO   |     | 0000-00-00 00:00:00 |       |
| command_line   | varchar(255) | NO   |     |                     |       |
| execution_time | double       | NO   |     | 0                   |       |
| return_code    | smallint(6)  | NO   |     | 0                   |       |
| output         | varchar(255) | NO   |     |                     |       |
| perfdata       | varchar(255) | NO   |     |                     |       |
+----------------+--------------+------+-----+---------------------+-------+
8 rows in set (0.00 sec)

mysql> select * from v_nagios where date(end_time) = '2010-08-27' into outfile '/tmp/data1.sql';
ERROR 1356 (HY000): View 'vistqa.v_nagios' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them

Server version: 5.0.51a-24+lenny4 (Debian)
[30 Aug 2010 11:52] Guido Serra
mysql> select * from v_nagios where date(end_time) = '2010-08-27' limit 0,2;
+--------------------+----------------------+---------------------+-------------------------------------------------------------------------------------------------------+----------------+-------------+----------------------------------------------------------+---------------------------------------------------------------------------------------+
| name1              | name2                | end_time            | command_line                                                                                          | execution_time | return_code | output                                                   | perfdata                                                                              |
+--------------------+----------------------+---------------------+-------------------------------------------------------------------------------------------------------+----------------+-------------+----------------------------------------------------------+---------------------------------------------------------------------------------------+
| kpi.XXXXX.de | KPI-DongleConnection | 2010-08-27 19:39:12 | /home/uml/apps/mon-scripts/dongle-connection.sh kpi.XXXXXX.de                                    |        3.03043 |           2 | Connection is not available                              | fail=1                                                                                |
| kpi.XXXXXX.es | KPI-Music            | 2010-08-27 19:39:05 | /home/uml/apps/qat/bin/nagios_test.sh AlbumAndTrackByAlbumWc kpi.XXXXX.es 40000 60000 KPI-Music |       27.86436 |           2 | Chain run with errors. Failed test case: TrackByTrackId. | rt=15925 t1=3805;t2=5757;t3=1175;t4=3168;t5=965;t6=1055;t7=0;t8=0;t9=0 fail=1 opco=es |
+--------------------+----------------------+---------------------+-------------------------------------------------------------------------------------------------------+----------------+-------------+----------------------------------------------------------+---------------------------------------------------------------------------------------+
2 rows in set (0.37 sec)

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.047 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.