Skip to content

Commit bd18c9f

Browse files
Merge [email protected]:/home/bk/mysql-5.1-new
into ndbmaster.mysql.com:/home/ndbdev/tomas/mysql-5.1-new
2 parents 37788da + 7678149 commit bd18c9f

File tree

7 files changed

+43
-14
lines changed

7 files changed

+43
-14
lines changed

include/heap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ extern int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
206206
uint reclength, ulong max_records, ulong min_records,
207207
HP_CREATE_INFO *create_info);
208208
extern int heap_delete_table(const char *name);
209+
extern void heap_drop_table(HP_INFO *info);
209210
extern int heap_extra(HP_INFO *info,enum ha_extra_function function);
210211
extern int heap_rename(const char *old_name,const char *new_name);
211212
extern int heap_panic(enum ha_panic_function flag);

sql/ha_heap.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,14 @@ int ha_heap::delete_table(const char *name)
477477
return error == ENOENT ? 0 : error;
478478
}
479479

480+
481+
void ha_heap::drop_table(const char *name)
482+
{
483+
heap_drop_table(file);
484+
close();
485+
}
486+
487+
480488
int ha_heap::rename_table(const char * from, const char * to)
481489
{
482490
return heap_rename(from,to);

sql/ha_heap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class ha_heap: public handler
9494
int indexes_are_disabled(void);
9595
ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key);
9696
int delete_table(const char *from);
97+
void drop_table(const char *name);
9798
int rename_table(const char * from, const char * to);
9899
int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info);
99100
void update_create_info(HA_CREATE_INFO *create_info);

sql/handler.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,6 +2062,14 @@ int handler::rename_table(const char * from, const char * to)
20622062
return error;
20632063
}
20642064

2065+
2066+
void handler::drop_table(const char *name)
2067+
{
2068+
close();
2069+
delete_table(name);
2070+
}
2071+
2072+
20652073
/*
20662074
Tell the storage engine that it is allowed to "disable transaction" in the
20672075
handler. It is a hint that ACID is not required - it is used in NDB for

sql/handler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,7 @@ class handler :public Sql_alloc
12871287
*/
12881288
virtual int rename_table(const char *from, const char *to);
12891289
virtual int delete_table(const char *name);
1290+
virtual void drop_table(const char *name);
12901291

12911292
virtual int create(const char *name, TABLE *form, HA_CREATE_INFO *info)=0;
12921293
virtual int create_handler_files(const char *name) { return FALSE;}

sql/sql_select.cc

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8848,16 +8848,8 @@ free_tmp_table(THD *thd, TABLE *entry)
88488848
if (entry->file)
88498849
{
88508850
if (entry->db_stat)
8851-
{
8852-
(void) entry->file->close();
8853-
}
8854-
/*
8855-
We can't call ha_delete_table here as the table may created in mixed case
8856-
here and we have to ensure that delete_table gets the table name in
8857-
the original case.
8858-
*/
8859-
if (!(test_flags & TEST_KEEP_TMP_TABLES) ||
8860-
entry->s->db_type == DB_TYPE_HEAP)
8851+
entry->file->drop_table(entry->s->table_name);
8852+
else
88618853
entry->file->delete_table(entry->s->table_name);
88628854
delete entry->file;
88638855
}

storage/heap/hp_create.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,16 @@ static void init_block(HP_BLOCK *block, uint reclength, ulong min_records,
234234
HP_PTRS_IN_NOD * block->level_info[i - 1].records_under_level);
235235
}
236236

237+
238+
static inline void heap_try_free(HP_SHARE *share)
239+
{
240+
if (share->open_count == 0)
241+
hp_free(share);
242+
else
243+
share->delete_on_close= 1;
244+
}
245+
246+
237247
int heap_delete_table(const char *name)
238248
{
239249
int result;
@@ -243,10 +253,7 @@ int heap_delete_table(const char *name)
243253
pthread_mutex_lock(&THR_LOCK_heap);
244254
if ((share= hp_find_named_heap(name)))
245255
{
246-
if (share->open_count == 0)
247-
hp_free(share);
248-
else
249-
share->delete_on_close= 1;
256+
heap_try_free(share);
250257
result= 0;
251258
}
252259
else
@@ -257,6 +264,17 @@ int heap_delete_table(const char *name)
257264
DBUG_RETURN(result);
258265
}
259266

267+
268+
void heap_drop_table(HP_INFO *info)
269+
{
270+
DBUG_ENTER("heap_drop_table");
271+
pthread_mutex_lock(&THR_LOCK_heap);
272+
heap_try_free(info->s);
273+
pthread_mutex_unlock(&THR_LOCK_heap);
274+
DBUG_VOID_RETURN;
275+
}
276+
277+
260278
void hp_free(HP_SHARE *share)
261279
{
262280
heap_share_list= list_delete(heap_share_list, &share->open_list);

0 commit comments

Comments
 (0)