Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-28455

CREATE TEMPORARY TABLES privilege is insufficient for SHOW COLUMNS

Details

    Description

      CREATE TEMPORARY TABLES privilege is supposed to allow all actions with temporary tables created by the session.
      However, while it also allows to run SHOW COLUMNS on such tables, it's not sufficient to get a result, it remains empty.
      Oddly, SHOW INDEX works.

      create database db;
      create user foo@localhost;
      grant create temporary tables on db.* to foo@localhost;
       
      --connect (con1,localhost,foo,,db)
      create temporary table tmp (a int, key(a));
      show create table tmp;
      show columns in tmp;
      show index in tmp;
       
      # Cleanup
      --disconnect con1
      --connection default
      drop database db;
      drop user foo@localhost;
      

      bb-10.9-anel 32274c3e8a4

      show columns in tmp;
      Field	Type	Null	Key	Default	Extra
      show index in tmp;
      Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment	Index_comment	Ignored
      tmp	1	a	1	a	A	NULL	NULL	NULL	YES	BTREE			NO
      

      Attachments

        Issue Links

          Activity

            Thanks elenst,
            have tried to test MySQL, seems there is bug too for show columns in <table>, which results with empty set, same as with MariaDB:

            mysql> select @@version;
            +-----------+
            | @@version |
            +-----------+
            | 8.0.29    |
            +-----------+
            1 row in set (0.00 sec)
            mysql> create user foo@localhost identified by '123';
            mysql> grant create temporary tables on test.* to foo@localhost;
            

            mysql> show grants for current_user;
            +----------------------------------------------------------------+
            | Grants for foo@localhost                                       |
            +----------------------------------------------------------------+
            | GRANT USAGE ON *.* TO `foo`@`localhost`                        |
            | GRANT CREATE TEMPORARY TABLES ON `test`.* TO `foo`@`localhost` |
            +----------------------------------------------------------------+
            2 rows in set (0.00 sec)
             
            mysql> create temporary table tmpbar (b int, key(b));
            Query OK, 0 rows affected (0.00 sec)
             
            mysql> show index in tmpbar;
            +--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
            | Table  | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression |
            +--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
            | tmpbar |          1 | b        |            1 | b           | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               | YES     | NULL       |
            +--------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+
            1 row in set (0.00 sec)
             
             
            mysql> show columns in tmpbar;
            Empty set (0.00 sec)
             
            mysql> insert into tmpbar values (3),(4);
            Query OK, 2 rows affected (0.00 sec)
            Records: 2  Duplicates: 0  Warnings: 0
             
            mysql> select * from tmpbar;
            +------+
            | b    |
            +------+
            |    3 |
            |    4 |
            +------+
            2 rows in set (0.00 sec)
             
            mysql> show columns in test.tmpbar;
            Empty set (0.00 sec)
            

            So regarding the decision, I guess we should stick to MySQL documentation CREATE TEMPORARY TABLES (without SELECT_ACL, as in case for base tables) is enough to get SHOW COLUMNS what is actually the real bug, right serg ?

            anel Anel Husakovic added a comment - Thanks elenst , have tried to test MySQL , seems there is bug too for show columns in <table> , which results with empty set, same as with MariaDB : mysql> select @@version; + -----------+ | @@version | + -----------+ | 8.0.29 | + -----------+ 1 row in set (0.00 sec) mysql> create user foo@localhost identified by '123' ; mysql> grant create temporary tables on test.* to foo@localhost; mysql> show grants for current_user ; + ----------------------------------------------------------------+ | Grants for foo@localhost | + ----------------------------------------------------------------+ | GRANT USAGE ON *.* TO `foo`@`localhost` | | GRANT CREATE TEMPORARY TABLES ON `test`.* TO `foo`@`localhost` | + ----------------------------------------------------------------+ 2 rows in set (0.00 sec)   mysql> create temporary table tmpbar (b int , key (b)); Query OK, 0 rows affected (0.00 sec)   mysql> show index in tmpbar; + --------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | + --------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+ | tmpbar | 1 | b | 1 | b | A | 0 | NULL | NULL | YES | BTREE | | | YES | NULL | + --------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+ 1 row in set (0.00 sec)     mysql> show columns in tmpbar; Empty set (0.00 sec)   mysql> insert into tmpbar values (3),(4); Query OK, 2 rows affected (0.00 sec) Records: 2 Duplicates: 0 Warnings: 0   mysql> select * from tmpbar; + ------+ | b | + ------+ | 3 | | 4 | + ------+ 2 rows in set (0.00 sec)   mysql> show columns in test.tmpbar; Empty set (0.00 sec) So regarding the decision, I guess we should stick to MySQL documentation CREATE TEMPORARY TABLES (without SELECT_ACL , as in case for base tables) is enough to get SHOW COLUMNS what is actually the real bug, right serg ?
            serg Sergei Golubchik added a comment - - edited

            Of course, CREATE TEMPORARY TABLES should be enough for SHOW COLUMNS to work on temporary tables.
            SHOW COLUMNS doesn't tell you anything you don't know, you've created the table, you already know all the columns it has, why would you ever need additional privileges to see what you already know?

            serg Sergei Golubchik added a comment - - edited Of course, CREATE TEMPORARY TABLES should be enough for SHOW COLUMNS to work on temporary tables. SHOW COLUMNS doesn't tell you anything you don't know, you've created the table, you already know all the columns it has, why would you ever need additional privileges to see what you already know?

            Yes, understood and implemented in PR #2180. Thanks.

            anel Anel Husakovic added a comment - Yes, understood and implemented in PR #2180. Thanks.

            OK to push

            cvicentiu Vicențiu Ciorbaru added a comment - OK to push

            Where is a 10.5 version of this patch? MDEV-21702 refactored TMP_TABLE_ACLS.

            marko Marko Mäkelä added a comment - Where is a 10.5 version of this patch? MDEV-21702 refactored TMP_TABLE_ACLS .

            People

              anel Anel Husakovic
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.