~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_handler.cc

  • Committer: Brian Aker
  • Date: 2008-08-16 22:34:15 UTC
  • mto: This revision was merged to the branch mainline in revision 346.
  • Revision ID: brian@tangent.org-20080816223415-n24esdpfcqi4pwpy
Refactor around classes. TABLE_LIST has been factored out of table.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
  the most natural (easiest, fastest) way to do it is to
22
22
  compute List<Item> field_list not in mysql_ha_read
23
 
  but in mysql_ha_open, and then store it in TABLE structure.
 
23
  but in mysql_ha_open, and then store it in Table structure.
24
24
 
25
25
  The problem here is that mysql_parse calls free_item to free all the
26
26
  items allocated at the end of every query. The workaround would to
34
34
 
35
35
/*
36
36
  There are two containers holding information about open handler tables.
37
 
  The first is 'thd->handler_tables'. It is a linked list of TABLE objects.
 
37
  The first is 'thd->handler_tables'. It is a linked list of Table objects.
38
38
  It is used like 'thd->open_tables' in the table cache. The trick is to
39
39
  exchange these two lists during open and lock of tables. Thus the normal
40
40
  table cache code can be used.
41
41
  The second container is a HASH. It holds objects of the type TABLE_LIST.
42
42
  Despite its name, no lists of tables but only single structs are hashed
43
43
  (the 'next' pointer is always NULL). The reason for theis second container
44
 
  is, that we want handler tables to survive FLUSH TABLE commands. A table
45
 
  affected by FLUSH TABLE must be closed so that other threads are not
 
44
  is, that we want handler tables to survive FLUSH Table commands. A table
 
45
  affected by FLUSH Table must be closed so that other threads are not
46
46
  blocked by handler tables still in use. Since we use the normal table cache
47
47
  functions with 'thd->handler_tables', the closed tables are removed from
48
48
  this list. Hence we need the original open information for the handler
49
49
  table in the case that it is used again. This information is handed over
50
50
  to mysql_ha_open() as a TABLE_LIST. So we store this information in the
51
 
  second container, where it is not affected by FLUSH TABLE. The second
 
51
  second container, where it is not affected by FLUSH Table. The second
52
52
  container is implemented as a hash for performance reasons. Consequently,
53
53
  we use it not only for re-opening a handler table, but also for the
54
54
  HANDLER ... READ commands. For this purpose, we store a pointer to the
55
 
  TABLE structure (in the first container) in the TBALE_LIST object in the
 
55
  Table structure (in the first container) in the TBALE_LIST object in the
56
56
  second container. When the table is flushed, the pointer is cleared.
57
57
*/
58
58
 
76
76
static void mysql_ha_close_table(THD *thd, TABLE_LIST *tables,
77
77
                                 bool is_locked)
78
78
{
79
 
  TABLE **table_ptr;
 
79
  Table **table_ptr;
80
80
 
81
81
  /*
82
82
    Though we could take the table pointer from hash_tables->table,
105
105
  else if (tables->table)
106
106
  {
107
107
    /* Must be a temporary table */
108
 
    TABLE *table= tables->table;
 
108
    Table *table= tables->table;
109
109
    table->file->ha_index_or_rnd_end();
110
110
    table->query_id= thd->query_id;
111
111
    table->open_by_handler= 0;