From 7bd4fb813a84e0c0d4b38c591d3a06aed682b148 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Tue, 12 Nov 2002 14:40:32 +0200 Subject: [PATCH] some code cleanup as per CTO's instructions plus a small bug fix with a corresponding test case.... --- mysql-test/r/derived.result | 3 +++ mysql-test/t/derived.test | 1 + sql/sql_derived.cc | 2 +- sql/sql_parse.cc | 4 ++-- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index b99664835a2..0290d0755d5 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -37,3 +37,6 @@ select * from (select 1); select a from (select 1 as a); a 1 +select 1 from (select 1); +1 +1 diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 6f32cfa0390..501d4db26fa 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -21,3 +21,4 @@ SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1); drop table if exists t1.t2,t3; select * from (select 1); select a from (select 1 as a); +select 1 from (select 1); diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index b4de767189e..7cbc1ea6db3 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -118,7 +118,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, TABLE_LIST *t) table->tmp_table=TMP_TABLE; if (!lex->describe) sl->exclude(); - t->db= (tables && tables->db && tables->db[0]) ? t->db : thd->db; + t->db=""; t->derived=(SELECT_LEX *)0; // just in case ... } } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 758c2c405e6..f16bc63636f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2717,7 +2717,7 @@ check_table_access(THD *thd, ulong want_access,TABLE_LIST *tables, TABLE_LIST *org_tables=tables; for (; tables ; tables=tables->next) { - if (tables->derived) + if (tables->derived || (tables->table && (int)tables->table->tmp_table)) continue; if ((thd->master_access & want_access) == (want_access & ~EXTRA_ACL) && thd->db) @@ -2735,7 +2735,7 @@ check_table_access(THD *thd, ulong want_access,TABLE_LIST *tables, found=1; } } - else if (tables->db && check_access(thd,want_access,tables->db,&tables->grant.privilege, + else if (check_access(thd,want_access,tables->db,&tables->grant.privilege, 0, no_errors)) return TRUE; }