mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Ugly merge of 3.23 changes into 4.0 - fix up needed
BitKeeper/etc/logging_ok: auto-union client/mysql.cc: Auto merged sql/mysqld.cc: Auto merged sql/sql_base.cc: Auto merged myisam/mi_search.c: the ugliest merge I've ever done! And I already see this has introduced a bug - will have to do a fix-up afterwards
This commit is contained in:
@ -111,74 +111,71 @@ static void check_unused(void)
|
||||
#define check_unused()
|
||||
#endif
|
||||
|
||||
int list_open_tables(THD *thd,List<char> *tables, const char *db,
|
||||
const char *wild)
|
||||
OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild)
|
||||
{
|
||||
int result = 0;
|
||||
uint col_access=thd->col_access;
|
||||
OPEN_TABLE_LIST **start_list, *open_list;
|
||||
TABLE_LIST table_list;
|
||||
char name[NAME_LEN*2];
|
||||
DBUG_ENTER("list_open_tables");
|
||||
|
||||
VOID(pthread_mutex_lock(&LOCK_open));
|
||||
bzero((char*) &table_list,sizeof(table_list));
|
||||
start_list= &open_list;
|
||||
open_list=0;
|
||||
|
||||
for (uint idx=0 ; result == 0 && idx < open_cache.records; idx++)
|
||||
{
|
||||
OPEN_TABLE_LIST *table;
|
||||
TABLE *entry=(TABLE*) hash_element(&open_cache,idx);
|
||||
if ((!entry->real_name) || strcmp(entry->table_cache_key,db))
|
||||
continue;
|
||||
if (wild && wild[0] && wild_compare(entry->real_name,wild))
|
||||
continue;
|
||||
if (db && !(col_access & TABLE_ACLS))
|
||||
{
|
||||
table_list.db= (char*) db;
|
||||
table_list.real_name= entry->real_name;/*real name*/
|
||||
table_list.grant.privilege=col_access;
|
||||
if (check_grant(thd,TABLE_ACLS,&table_list,1))
|
||||
continue;
|
||||
}
|
||||
/* need to check if he have't already listed it */
|
||||
|
||||
List_iterator<char> it(*tables);
|
||||
char *table_name;
|
||||
int check = 0;
|
||||
while (check == 0 && (table_name=it++))
|
||||
if ((!entry->real_name))
|
||||
continue; // Shouldn't happen
|
||||
if (wild)
|
||||
{
|
||||
if (!strcmp(table_name,entry->real_name))
|
||||
check++;
|
||||
strxmov(name,entry->table_cache_key,".",entry->real_name,NullS);
|
||||
if (wild_compare(name,wild))
|
||||
continue;
|
||||
}
|
||||
if (check)
|
||||
|
||||
/* Check if user has SELECT privilege for any column in the table */
|
||||
table_list.db= (char*) entry->table_cache_key;
|
||||
table_list.real_name= entry->real_name;
|
||||
table_list.grant.privilege=0;
|
||||
if (check_table_access(thd,SELECT_ACL | EXTRA_ACL,&table_list))
|
||||
continue;
|
||||
|
||||
if (tables->push_back(thd->strdup(entry->real_name)))
|
||||
|
||||
/* need to check if we haven't already listed it */
|
||||
for (table= open_list ; table ; table=table->next)
|
||||
{
|
||||
result = -1;
|
||||
if (!strcmp(table->table,entry->real_name) &&
|
||||
!strcmp(table->db,entry->table_cache_key))
|
||||
{
|
||||
if (entry->in_use)
|
||||
table->in_use++;
|
||||
if (entry->locked_by_name)
|
||||
table->locked++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (table)
|
||||
continue;
|
||||
if (!(*start_list = (OPEN_TABLE_LIST *)
|
||||
sql_alloc(sizeof(OPEN_TABLE_LIST)+entry->key_length)))
|
||||
{
|
||||
open_list=0; // Out of memory
|
||||
break;
|
||||
}
|
||||
(*start_list)->table=(strmov((*start_list)->db=(char*) ((*start_list)+1),
|
||||
entry->table_cache_key)+1,
|
||||
entry->real_name);
|
||||
(*start_list)->in_use= entry->in_use ? 1 : 0;
|
||||
(*start_list)->locked= entry->locked_by_name ? 1 : 0;
|
||||
start_list= &(*start_list)->next;
|
||||
}
|
||||
|
||||
VOID(pthread_mutex_unlock(&LOCK_open));
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
char*
|
||||
query_table_status(THD *thd,const char *db,const char *table_name)
|
||||
{
|
||||
int cached = 0, in_use = 0;
|
||||
char info[256];
|
||||
|
||||
for (uint idx=0 ; idx < open_cache.records; idx++)
|
||||
{
|
||||
TABLE *entry=(TABLE*) hash_element(&open_cache,idx);
|
||||
if (strcmp(entry->table_cache_key,db) ||
|
||||
strcmp(entry->real_name,table_name))
|
||||
continue;
|
||||
|
||||
cached++;
|
||||
if (entry->in_use)
|
||||
in_use++;
|
||||
}
|
||||
|
||||
sprintf(info, "cached=%d, in_use=%d", cached, in_use);
|
||||
return thd->strdup(info);
|
||||
DBUG_RETURN(open_list);
|
||||
}
|
||||
|
||||
|
||||
@ -258,7 +255,7 @@ send_fields(THD *thd,List<Item> &list,uint flag)
|
||||
if (my_net_write(&thd->net, (char*) packet->ptr(),packet->length()))
|
||||
break; /* purecov: inspected */
|
||||
}
|
||||
send_eof(&thd->net,(test_flags & TEST_MIT_THREAD) ? 0: 1);
|
||||
send_eof(&thd->net);
|
||||
return 0;
|
||||
err:
|
||||
send_error(&thd->net,ER_OUT_OF_RESOURCES); /* purecov: inspected */
|
||||
|
Reference in New Issue
Block a user