summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2000-09-14 02:39:07 +0300
committerunknown <monty@donna.mysql.com>2000-09-14 02:39:07 +0300
commitd5964ba20ca4c00a443c185186def44bb90831b3 (patch)
tree47d3199e561726437875c3247556ac5797525366 /sql/sql_parse.cc
parent9e37676d7cd9ca30a05025b9fcc3424c4e4a1932 (diff)
downloadmariadb-git-d5964ba20ca4c00a443c185186def44bb90831b3.tar.gz
Fixes for MERGE TABLES and HEAP tables
Docs/manual.texi: Updated MERGE table stuff + more extra/perror.c: Added missing error messages include/myisammrg.h: Fixes for MERGE TABLE include/queues.h: Fixes for MERGE TABLE isam/isamlog.c: Fixed hard bug myisam/mi_log.c: cleanup myisam/mi_open.c: Fixed file name format in myisam log myisam/myisamlog.c: Bug fixes myisammrg/mymrgdef.h: Fixes for MERGE TABLE myisammrg/myrg_create.c: Fixes for MERGE TABLE myisammrg/myrg_open.c: Fixes for MERGE TABLE myisammrg/myrg_queue.c: Fixes for MERGE TABLE myisammrg/myrg_rfirst.c: Fixes for MERGE TABLE myisammrg/myrg_rkey.c: Fixes for MERGE TABLE myisammrg/myrg_rlast.c: Fixes for MERGE TABLE myisammrg/myrg_rnext.c: Fixes for MERGE TABLE myisammrg/myrg_rprev.c: Fixes for MERGE TABLE myisammrg/myrg_rrnd.c: Fixes for MERGE TABLE mysql.proj: update mysys/queues.c: Fixed bug when using reverse queues sql-bench/test-insert.sh: Separated some things to get better timings sql/ha_heap.cc: Fixed heap table bug sql/ha_heap.h: Fixed heap table bug sql/ha_myisam.h: Fixed wrong max_keys sql/ha_myisammrg.cc: Fixed MERGE TABLES sql/ha_myisammrg.h: Fixed MERGE TABLES sql/handler.h: Fix for MERGE TABLES and HEAP tables sql/lex.h: Fixed MERGE TABLES sql/mysql_priv.h: Cleanup of code sql/sql_acl.cc: Fixed that privilege tables are flushed at start sql/sql_lex.h: Fixed MERGE TABLES sql/sql_parse.cc: Fixed MERGE TABLES sql/sql_select.cc: Fixes for HEAP tables sql/sql_table.cc: Cleanup sql/sql_yacc.yy: Fixed MERGE TABLES
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc50
1 files changed, 36 insertions, 14 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index a2ef4354521..97eb7c80b50 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -38,8 +38,9 @@ extern "C" pthread_mutex_t THR_LOCK_keycache;
extern "C" int gethostname(char *name, int namelen);
#endif
-static bool check_table_access(THD *thd,uint want_access,TABLE_LIST *tables);
+static bool check_table_access(THD *thd,uint want_access, TABLE_LIST *tables);
static bool check_db_used(THD *thd,TABLE_LIST *tables);
+static bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *tables);
static bool check_dup(THD *thd,const char *db,const char *name,
TABLE_LIST *tables);
static void mysql_init_query(THD *thd);
@@ -504,9 +505,9 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd)
if(!(table=open_ltable(thd, table_list, TL_READ_NO_INSERT)))
DBUG_RETURN(1);
- if(check_access(thd, SELECT_ACL, db, &table_list->grant.privilege))
+ if (check_access(thd, SELECT_ACL, db, &table_list->grant.privilege))
goto err;
- if(grant_option && check_grant(thd, SELECT_ACL, table_list))
+ if (grant_option && check_grant(thd, SELECT_ACL, table_list))
goto err;
thd->free_list = 0;
@@ -988,10 +989,12 @@ mysql_execute_command(void)
break;
case SQLCOM_CREATE_TABLE:
-#ifdef DEMO_VERSION
- send_error(&thd->net,ER_NOT_ALLOWED_COMMAND);
-#else
- if (check_access(thd,CREATE_ACL,tables->db,&tables->grant.privilege))
+ if (!tables->db)
+ tables->db=thd->db;
+ if (check_access(thd,CREATE_ACL,tables->db,&tables->grant.privilege) ||
+ check_merge_table_access(thd, tables->db,
+ (TABLE_LIST *)
+ lex->create_info.merge_list.first))
goto error; /* purecov: inspected */
if (grant_option)
{
@@ -1072,7 +1075,6 @@ mysql_execute_command(void)
if (grant_option && check_grant(thd,INDEX_ACL,tables))
goto error;
res = mysql_create_index(thd, tables, lex->key_list);
-#endif
break;
case SQLCOM_SLAVE_START:
@@ -1082,7 +1084,6 @@ mysql_execute_command(void)
stop_slave(thd);
break;
-
case SQLCOM_ALTER_TABLE:
#if defined(DONT_ALLOW_SHOW_COMMANDS)
send_error(&thd->net,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
@@ -1096,11 +1097,16 @@ mysql_execute_command(void)
res=0;
break;
}
+ if (!tables->db)
+ tables->db=thd->db;
if (!lex->db)
lex->db=tables->db;
if (check_access(thd,ALTER_ACL,tables->db,&tables->grant.privilege) ||
- check_access(thd,INSERT_ACL | CREATE_ACL,lex->db,&priv))
- goto error; /* purecov: inspected */
+ check_access(thd,INSERT_ACL | CREATE_ACL,lex->db,&priv) ||
+ check_merge_table_access(thd, tables->db,
+ (TABLE_LIST *)
+ lex->create_info.merge_list.first))
+ goto error; /* purecov: inspected */
if (!tables->db)
tables->db=thd->db;
if (grant_option)
@@ -1354,7 +1360,7 @@ mysql_execute_command(void)
res = mysql_drop_index(thd, tables, lex->drop_list);
break;
case SQLCOM_SHOW_DATABASES:
-#if defined(DONT_ALLOW_SHOW_COMMANDS) || defined(DEMO_VERSION)
+#if defined(DONT_ALLOW_SHOW_COMMANDS)
send_error(&thd->net,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
DBUG_VOID_RETURN;
#else
@@ -1810,6 +1816,22 @@ static bool check_db_used(THD *thd,TABLE_LIST *tables)
}
+static bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *table_list)
+{
+ int error=0;
+ if (table_list)
+ {
+ /* Force all tables to use the current database */
+ TABLE_LIST *tmp;
+ for (tmp=table_list; tmp ; tmp=tmp->next)
+ tmp->db=db;
+ error=check_table_access(thd, SELECT_ACL | UPDATE_ACL | DELETE_ACL,
+ table_list);
+ }
+ return error;
+}
+
+
/****************************************************************************
Check stack size; Send error if there isn't enough stack to continue
****************************************************************************/
@@ -2462,7 +2484,7 @@ static int start_slave(THD* thd , bool net_report)
if(!thd) thd = current_thd;
NET* net = &thd->net;
const char* err = 0;
- if(check_access(thd, PROCESS_ACL, any_db))
+ if (check_access(thd, PROCESS_ACL, any_db))
return 1;
pthread_mutex_lock(&LOCK_slave);
if(!slave_running)
@@ -2497,7 +2519,7 @@ static int stop_slave(THD* thd, bool net_report )
NET* net = &thd->net;
const char* err = 0;
- if(check_access(thd, PROCESS_ACL, any_db))
+ if (check_access(thd, PROCESS_ACL, any_db))
return 1;
pthread_mutex_lock(&LOCK_slave);