diff options
author | monty@hundin.mysql.fi <> | 2001-08-15 20:09:20 +0300 |
---|---|---|
committer | monty@hundin.mysql.fi <> | 2001-08-15 20:09:20 +0300 |
commit | f8e6e74cb642dbe3813f7c0201d261a904500603 (patch) | |
tree | 74910ff17601e143822ae450210979f04bb4fc85 /sql | |
parent | 68c2afa8a58ba7eaff364299ffc9c416bb10a862 (diff) | |
download | mariadb-git-f8e6e74cb642dbe3813f7c0201d261a904500603.tar.gz |
Fix problem with not getting 'No Database Selected' error
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_base.cc | 17 | ||||
-rw-r--r-- | sql/sql_parse.cc | 12 |
2 files changed, 14 insertions, 15 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 31cadf6f778..2a9043cc0d7 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1323,7 +1323,7 @@ int open_tables(THD *thd,TABLE_LIST *start) { if (!tables->table && !(tables->table=open_table(thd, - tables->db ? tables->db : thd->db, + tables->db, tables->real_name, tables->name, &refresh))) { @@ -1380,7 +1380,7 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type) DBUG_ENTER("open_ltable"); thd->proc_info="Opening table"; - while (!(table=open_table(thd,table_list->db ? table_list->db : thd->db, + while (!(table=open_table(thd,table_list->db, table_list->real_name,table_list->name, &refresh)) && refresh) ; if (table) @@ -1612,9 +1612,7 @@ find_field_in_tables(THD *thd,Item_field *item,TABLE_LIST *tables) for (; tables ; tables=tables->next) { if (!strcmp(tables->name,table_name) && - (!db || - (tables->db && !strcmp(db,tables->db)) || - (!tables->db && !strcmp(db,thd->db)))) + (!db || !strcmp(db,tables->db))) { found_table=1; Field *find=find_field_in_table(thd,tables->table,name,length, @@ -1854,8 +1852,7 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name, check_grant_all_columns(thd,SELECT_ACL,table) ) DBUG_RETURN(-1); if (!table_name || (!strcmp(table_name,tables->name) && - (!db_name || !tables->db || - !strcmp(tables->db,db_name)))) + (!db_name || !strcmp(tables->db,db_name)))) { Field **ptr=table->field,*field; thd->used_tables|=table->map; @@ -2079,7 +2076,8 @@ int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys) create_info.db_type=DB_TYPE_DEFAULT; DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name, &create_info, table_list, - fields, keys, drop, alter, (ORDER*)0, FALSE, DUP_ERROR)); + fields, keys, drop, alter, (ORDER*)0, FALSE, + DUP_ERROR)); } @@ -2094,7 +2092,8 @@ int mysql_drop_index(THD *thd, TABLE_LIST *table_list, List<Alter_drop> &drop) create_info.db_type=DB_TYPE_DEFAULT; DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name, &create_info, table_list, - fields, keys, drop, alter, (ORDER*)0, FALSE, DUP_ERROR)); + fields, keys, drop, alter, (ORDER*)0, FALSE, + DUP_ERROR)); } /***************************************************************************** diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 494af89cc5b..46906914fd4 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1810,16 +1810,14 @@ mysql_execute_command(void) DBUG_VOID_RETURN; #else { - char *db=tables->db ? tables->db : thd->db; - if (!db) + char *db=tables->db; + if (!*db) { send_error(&thd->net,ER_NO_DB_ERROR); /* purecov: inspected */ goto error; /* purecov: inspected */ } remove_escape(db); // Fix escaped '_' remove_escape(tables->name); - if (!tables->db) - tables->db=thd->db; if (check_access(thd,SELECT_ACL | EXTRA_ACL,db,&thd->col_access)) goto error; /* purecov: inspected */ tables->grant.privilege=thd->col_access; @@ -1837,7 +1835,7 @@ mysql_execute_command(void) DBUG_VOID_RETURN; #else { - char *db=tables->db ? tables->db : thd->db; + char *db=tables->db; if (!db) { send_error(&thd->net,ER_NO_DB_ERROR); /* purecov: inspected */ @@ -2178,7 +2176,7 @@ check_access(THD *thd,uint want_access,const char *db, uint *save_priv, else save_priv= &dummy; - if (!db && !thd->db && !dont_check_global_grants) + if (!db[0] && !thd->db && !dont_check_global_grants) { send_error(&thd->net,ER_NO_DB_ERROR); /* purecov: tested */ return TRUE; /* purecov: tested */ @@ -2725,6 +2723,8 @@ add_proc_to_list(Item *item) static void remove_escape(char *name) { + if (!*name) // For empty DB names + return; char *to; #ifdef USE_MB char *strend=name+(uint) strlen(name); |